使用vue-cli构建vue3项目时,一直有警告: Feature flag __VUE_PROD_HYDRATION_MISMATCH_DETAILS__ is not explicitly defined. You are running the esm-bundler build of Vue, which expects these compile-time feature flags to be globally injected via the bundler config in order to get better tree-shaking in the production bundle.
未明确定义功能标志__VUE_PROD_HYDRATION_ISMATCH_DETAILS__。您正在运行Vue的esm-bundler构建,它希望通过bundler配置全局注入这些编译时功能标志,以便在生产捆绑包中更好地进行树抖动。
解决方法:
vue.config.js添加以下代码
chainWebpack: (config) => { config.plugin('define').tap((definitions) => { Object.assign(definitions[0], { __VUE_OPTIONS_API__: 'true', __VUE_PROD_DEVTOOLS__: 'false', __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: 'false' }) return definitions }) },
复制
成功解决