场景

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

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

然后报如下错误:
VueCli 添加自定义组件报错

解决方案

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

module.exports = {
  runtimeCompiler: true
};

相关文章:

  • 2022-12-23
  • 2021-06-01
  • 2021-10-02
  • 2021-04-10
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-04-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-11
  • 2021-11-24
相关资源
相似解决方案