VueCli 添加自定义组件报错

场景

使用vuecli创建项目,然后添加自定义组件:

Vue.component("button-counter", {
  data() {
    return {
      count: 0
    };
  },
  template: `
    <button @click="count++">you have click me {{count}} times</button>
  `
});

然后报如下错误:

解决方案

在vue.config.js中添加如下配置:

module.exports = {
  runtimeCompiler: true
};
原文地址:https://www.cnblogs.com/Peter2014/p/13140980.html