相关文章推荐
健壮的鸵鸟  ·  pandas isin函数 - CSDN文库·  1 年前    · 
个性的小虾米  ·  python ...·  2 年前    · 
重情义的黄瓜  ·  angular - Type 'null' ...·  2 年前    · 
低调的钱包  ·  C#/VB.NET ...·  2 年前    · 


一、外部文件 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
}


二、引入 config.js 里面的常量和方法

import {config,formatXml} from '../config' // 记得带上{}花括号