一、問題情況
nuxt 執行報錯 :
WARN Though the "loose" option was set to "false" in your @babel/preset-env config, it will not be used for @babel/plugin-proposal-private-methods since the "loose" mode option was set to "true" for @babel/plugin-proposal-class-properties.
The "loose" option must be the same for @babel/plugin-proposal-class-properties, @babel/plugin-proposal-private-methods and @babel/plugin-proposal-private-property-in-object (when they are enabled): you can silence this warning by explicitly adding ["@babel/plugin-proposal-private-methods", { "loose": true }] to the "plugins" section of your Babel config
一直瘋狂的報這個警告,不知道什么原因。
二、問題解決
遇到這情況,在 nuxt.config.js 的 build 加上該插件就行了,注意位置,別放錯地方了
build: { parallel: true, babel:{ plugins:[ ["@babel/plugin-proposal-private-methods", { "loose": true }] ] } }
加上這個配置即可。
