如何使用vue.js在@click事件上添加两个方法? [英] How to add two methods on a @click event using vue.js?
本文介绍了如何使用vue.js在@click事件上添加两个方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的代码,我基本上想将CHANGEBUTTONS添加到看起来像@click的on click事件中.
This is my code and i basically want to add CHANGEBUTTONS to the on click event that looks like @click.
<button @click="enviarform2" value="Delete from favorites" style="font-weight: 700;color:#428bca;margin-left:30px;height:30px;border-radius:4px" name="delete" v-else>Delete from favorites</button>
<script>
new Vue({
el:'#app',
data:{
show: true,
paletteid : <?=$palette_id;?>,
action: "add",
action2: "delete",
number: ""
},
methods: {
enviarform: function() {
axios.post('/validarfavorite.php', {
paletteid: this.paletteid,
action: this.action
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
this.number = "Yours plus ";
},
enviarform2: function() {
axios.post('/validarfavorite.php', {
paletteid: this.paletteid,
action2: this.action2
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
this.number = "Minus yours plus ";
},
changebuttons: function() {
this.show = !this.show;
}
}
});
</script>
我尝试了方法1和方法2以及处理程序,但是没有用.希望你知道!
I have tried with method 1 and method 2 and handler but it didnt work. Hope you know!
推荐答案
查看全文