1、外部文件config.js
第一種寫法
//常量的定義 const config = { baseurl:'http://172.16.114.5:8088/MGT2' } //函數的定義 function formatXml(text) { return text } //導出 {常量名、函數名} export {config,formatXml}
第二種寫法
//常量的定義 export const config = { baseurl:'http://172.16.114.5:8088/MGT2' } //函數的定義 export function formatXml(text) { return text }
2、引入config.js里面的常量和方法
import {config,formatXml} from '../config'//記得帶上{}花括號