1.根目录下新增一个《.env.hk》文件
VUE_APP_FOR='hk'
NODE_ENV='production'
2.在/package.json中增加运行和打包命令
"serve": "eslint --fix src && vue-cli-service serve",
"serveHK": "eslint --fix src && vue-cli-service serve --mode hk",
"build": "vue-cli-service build",
"buildHK": "vue-cli-service build --mode hk",
3.在/src/config/index.js中增加:
const appFor = process.env.VUE_APP_FOR
export default {
...
appFor: appFor
}
4.页面中获取变量
mounted () {
console.log(this.$Config.appFor)
}
网友评论