- 在 .webpackrc.js 配置
const path = require('path');
export default {
externals: {
// 挂在全局ip地址
'Config': JSON.stringify(process.env.ENV === 'production' ? {
// serverUrl: "http://192.168.0.117:7001",
serverUrl: "http://localhost:7001",
// setUrl:"http://192.168.0.117",
setUrl: "http://localhost",
} : {
// serverUrl: "http://192.168.0.117:7001",
serverUrl: "http://localhost:7001",
// setUrl:"http://192.168.0.117",
setUrl: "http://localhost",
})
},
};
页面使用
let Config=require("Config")//引入
Config.serverUrl//使用