遇到错误 You are using the runtime-only build of Vue where the template compiler is not available. Either pre-compile the templates into render functions, or use the compiler-included build

错误描述:

您正在使用Vue的仅运行时版本,而模板编译器不可用。可以将模板预编译为渲染函数,也可以使用包含编译器的内部版本

解决办法

  1. 这样更改您的webpack.config.js或App.vue:
  • webpack.config.js

    resolve: { alias: { vue: 'vue/dist/vue.esm.js' } }

  • 应用程序

    new Vue({ el: '#app', router, render: h => h(App) })

提示:

  • 如果您是通过@ vue / cli创建的应用程序,则应将代码添加到vue.config.js中,如下所示:

module.exports = { runtimeCompiler: true, }

转载于

资料解释