【发布时间】:2021-10-25 03:23:33
【问题描述】:
所以我有一个带有按钮的页面。单击此按钮时,我希望显示文本,并且每次单击该按钮时,我希望文本显示如下:
这是我的代码:
<v-row>
<component
v-for="(component, index) in components"
:key="index"
:is="component"/>
</v-row>
<v-row justify="left" class="ml-3">
<v-btn class="elevation-7 grey darken-1 btn" @click="add">Click me</v-btn>
</v-row>
<script>
import Vue from 'vue'
Vue.component('component', {
template: '<p>component</p>'
})
export default {
data: () => {
return {
components: [Comp]
};
},
methods: {
add: function () {
this.components.push(Comp)
}
}
}
</script>
然而,当我点击按钮时,什么都没有出现?我真的很感激一些帮助,因为我不明白这一点。
更新
我检查了控制台,我看到了这个:
[Vue warn]: 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.
然后此错误指向 this.components.push(Comp) 。在 vue.config.js 中我添加了 runtimeCompiler: true 但此错误仍然存在并且文本没有出现。
这都是在 vuejs + electron 上完成的。
【问题讨论】:
标签: javascript vue.js electron