So, I'm using an onclick function to toggle a div's visibility, like so:
<div class="div1" v-show="expandDiv">
<div class="div2" v-on:click="expandDiv = !expandDiv">
This works great, but I'm getting problems when I want to use two on-clicks. I have a button which I want to use to run a function that adds items to a cart (addCart(item)) and I also want this function toggle the visibility of my div. Now, you can't two v-on:click so I created another function:
expander() {
cartAdd(item);
expandDiv = !expandDiv;
}
when I run this function on my v-on:click it doesn't seem to want to work as it only adds it to the cart, but doesnt expand my div. I'm probably syntactically wrong but I can't find a solution.
Would greatly appreciate some help on this one!
尝试:
this.expandDiv = !this.expandDiv
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.