美文网首页
vue运行时渲染报错

vue运行时渲染报错

作者: shiyuwudi | 来源:发表于2022-01-13 12:49 被阅读0次
  1. 报错内容: [Vue warn]: You are using the runtime-only build of Vue where the template compiler is not available
  2. 报错原因:在vue运行时内部渲染组件就会报错。(代码在最下面)
  3. 解决方法:如果是vue-cli创建的项目,会有vue.config.js,在里面新增一条:runtimeCompiler: true 即可,这个配置项允许在vue实例内部再次挂载新的vue实例。
  4. 为什么你会报这个错?在将之前做的服务端渲染的项目代码迁移到纯前端vue的时候遇到的。
// 导致报错的代码
new Vue({
  ...
}).mount(...);
// 解决方法
// vue.config.js
module.exports = {
  ...,
  runtimeCompiler: true,
};

相关文章

网友评论

      本文标题:vue运行时渲染报错

      本文链接:https://www.haomeiwen.com/subject/ygencrtx.html