我使用的是Vue-js-modal。
在我的模板上有以下内容:
<modal name="hello-world">
hello, world!
</modal>在我的Vue上,我有一个类似这样的方法:
showModal() {
this.$modal.show('hello-world');
}如何测试此方法(showModal)?
发布于 2020-05-10 22:03:06
通常,在Vue中,可以使用refs访问DOM,如下所示:
<modal ref="$myModal" name="hello-world">
hello, world!
</modal>
...
methods: {
testModal(){
this.$refs.$myModal.show()
}
}然后,如果你的模式弹出,它就能工作!
https://stackoverflow.com/questions/61713216
复制相似问题