问题:浏览器控制台会输出warning,提示:ReferenceError: __VUE_OPTIONS_API__, __VUE_PROD_DEVTOOLS__ is not defined.
官方文档解释为:
Starting with 3.0.0-rc.3,
esm-bundler
builds now exposes global feature flags that can be overwritten at compile time:
__VUE_OPTIONS_API__
(enable/disable Options API support, default:true
)__VUE_PROD_DEVTOOLS__
(enable/disable devtools support in production, default:false
)The build will work without configuring these flags, however it is strongly recommended to properly configure them in order to get proper tree-shaking in the final bundle. To configure these flags:
- webpack: use DefinePlugin
- Rollup: use @rollup/plugin-replace
- Vite: configured by default, but can be overwritten using the
define
optionNote: the replacement value must be boolean literals and cannot be strings, otherwise the bundler/minifier will not be able to properly evaluate the conditions.
就是在vue@3.0.0-rc.3版本开始,强烈推荐我们设置 __VUE_OPTIONS_API__, __VUE_PROD_DEVTOOLS__ 两个属性,
例如使用 DefinePlugin,我们在webpack的plugins中可以这样设置:
1 new webpack.DefinePlugin({ 2 '__VUE_OPTIONS_API__': true, 3 '__VUE_PROD_DEVTOOLS__': false 4 })
PS: 这里要注意设置的值得是boolean类型!
设置完控制台将不会再提示!
参考文档: