Vue @ and @
one,@
question:
A click event is added to the parent element, and the click event is also added to the child element below. At this time, I want to click the child element to get the click event of the child element, but it triggers the event of the parent element:
<view class="footer-box" @click="clickCard"> <view @click="footerClick('like')"><text class="footer-box__item">like</text></view> <view @click="footerClick('Comment')"><text class="footer-box__item">Comment</text></view> <view @click="footerClick('share')"><text class="footer-box__item">share</text></view> </view>
At this point, we need to use the @:Stop event bubble method to solve this problem:
<view class="footer-box" @click="clickCard"> <view @="footerClick('like')"><text class="footer-box__item">like</text></view> <view @="footerClick('Comment')"><text class="footer-box__item">Comment</text></view> <view @="footerClick('share')"><text class="footer-box__item">share</text></view> </view>
two,@
There is also a similar method: @: Block the default behavior of events,
For example:
Write a tag a in the code and click it to jump to the target link web page:
<view class="example-body"> <a href="" rel="external nofollow" rel="external nofollow" >Baidu</a> </view>
But if we don't want it to jump but still want to use the a tag, we need to use the @ method at this time:
<view class="example-body"> <a href="" rel="external nofollow" rel="external nofollow" @='notLink'>Baidu</a> </view>
Summarize
The above is personal experience. I hope you can give you a reference and I hope you can support me more.