ReferenceError: __VUE_OPTIONS_API__, __VUE_PROD_DEVTOOLS__ is not defined


問題:瀏覽器控制台會輸出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:

Note: 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類型!

設置完控制台將不會再提示!

 

參考文檔:

Bundler Build Feature Flags:https://github.com/vuejs/core/tree/main/packages/vue#bundler-build-feature-flags


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM