本文介绍了如何在toastr内的按钮上处理click事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想处理toastr中的按钮点击事件。我正在使用这个库:
I want to handle the button click event inside the toastr. I am using this library: https://www.npmjs.com/package/vue-toastr-2
这是我的代码:
var app = new Vue({
el: '#app',
data: {
message: 'vue-toastr-2'
},
created: function() {
this.$toastr.success('Click here to fire an event <button @click="clickMe">Hello</button>', 'Title');
},
methods: {
clickMe() {
alert('Clicked');
// write some more code
}
}
})
基本上我想要 clickMe $ c $单击c>,我应该调用组件内部的函数。我该怎么做?
Basically I want that when clickMe
is clicked, my function inside the component should get called. How would I do this?
这是我的jsfiddle:
This is my jsfiddle: https://jsfiddle.net/75154x8w/2/
推荐答案
var app = new Vue({
el: '#app',
data: {
message: 'vue-toastr-2'
},
created: function() {
this.$toastr.success('Click here to fire an event <button onclick="app.clickMe()">Hello</button>', 'Title');
},
methods: {
clickMe() {
alert('Clicked');
}
}
})
这篇关于如何在toastr内的按钮上处理click事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!