gpt4 book ai didi

javascript - 如何处理 toastr 中按钮的点击事件?

转载 作者:行者123 更新时间:2023-11-30 20:58:37 25 4
gpt4 key购买 nike

我想处理 toastr 中的按钮点击事件。我正在使用这个库: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 时,应该调用我在组件中的函数。我该怎么做?

这是我的 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');
}
}
})

关于javascript - 如何处理 toastr 中按钮的点击事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47362579/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com