在Vue中是否可以在DOM中插入一个新元素并从中调用一个方法,如下所示? 以下内容“什么也没有发生”无效。
app-argument
如果不是,那么在Vue中完成类似任务的方法是什么?
答案 0 :(得分:1)
不。我们在VueJS中不这样做。 对于这种情况,我将使用v-if / v-show来实现。
<div v-if="isConfirm">
<div>Are you sure?</div>
<div>
<button @click="cancel" >CANCEL</button>
<button @click="delete" >DELETE</button>
</div>
</div>
稍后输入数据
data(){
return {
isConfirm: false
}
},
method:{
Popup(){
this.isConfirm = true;
}
}