Vue CLI3:在main.js中挂载不是App.vue的多个组件

所以我做了以下

  1. mkdir test && cd test
  2. vue create dev
  3. vue add vuetify
  4. 将(3)和(4)中的所有配置文件移至一个目录(例如,在test/下)
  5. vue.config.js更新为以下内容:
// vue.config.js
module.exports = {
  "transpileDependencies": [
    "vuetify"
  ],pages: {
    index: {
      entry: 'dev/src/main.js',// <--- I changed the root of the project so need to update entry
      template: 'dev/public/index.html',filename: 'index.html',}
  },devserver: {
    overlay: {
      warnings: true,errors: true
    }
  }
}

这有效,当我从npm run serve运行test/时感到很高兴。

我想做的是在/dev/src/main.js中导入并安装多个组件。我可以安装任意数量的特定组件dev/src/App.vue,但是如果我尝试加载组件/dev/src/components/CountButton.vue(一个显示其被点击次数的按钮),然后尝试将其安装在{{1} }该组件已安装,但HTML不会更新。

main.js

我将<template> <div class=""> <v-btn @click="count"> test {{amount}} </v-btn> </div> </template> <script> import {VBtn} from 'vuetify/lib' // <---- for tree shaking & a la carte export default { name: 'CountButton',components: { VBtn },data: () =>({ amount: 0 }),methods:{ count() { this.amount += 1 } } } </script> 更改为的位置

main.js

例如我单击,它始终显示“ test 0”,尽管vue检查器会显示该数量并递增。

我该如何解决?

taoguolin 回答:Vue CLI3:在main.js中挂载不是App.vue的多个组件

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2971119.html

大家都在问