请教关于 vue-cli 中环境变量 process.env.VUE_APP_的问题(vue2)

14次阅读

共计 243 个字符,预计需要花费 1 分钟才能阅读完成。

在.env 文件中设置了 VUE_APP_TITLE=My App,然后以下代码

// 代码块 1
if (process.env.VUE_APP_TITLE === 'My App1') {import('./child1')
 }
// 代码块 2
if (['My App1'].indexOf(process.env.VUE_APP_TITLE) > -1) {import('./child2')
 }

打包后的代码,代码块 1 是不存在了,然而代码块 2 还在。
如果都是在编译时就处理了环境变量,为什么代码块 2 的条件不会计算呢?
谢谢。

正文完
 0