[Vue warn]: Component provided template option but runtime compilation is not supported in this build of Vue. Configure your bundler to alias "vue" to "vue/dist/vue.esm-bundler.js".

发布时间 2024-01-11 18:17:13作者: ziChin

这个警告是因为你提供了一个模板选项(template option),但在当前的Vue构建版本中不支持运行时编译。解决该问题的方法是将你的打包工具配置别名(alias)将 "vue" 指向 "vue/dist/vue.esm-bundler.js"。

具体来说,如果你使用的是Webpack或者vite,可以在 webpack.config.js 或者 vite.config.ts 文件中添加以下配置:

module.exports = {
  // ...
  resolve: {
    alias: {
      'vue$': 'vue/dist/vue.esm-bundler.js'
    }
  }
}

这样配置后,打包工具在引入 "vue" 模块时会自动使用带有运行时编译的捆绑包。