In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces the relevant knowledge of "how to judge whether the button can be clicked according to the conditions". In the operation of the actual case, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Judge whether the button can be clicked according to the condition
When the button is not clickable in a particular environment, the click event needs to be controlled according to judgment.
Method 1: use v-if and v-else to judge method 2: add a variable to determine that data () {return {isDisabled:true, / / can be clicked when it is true, but not clickable when false
Both methods are fine, but the second one writes relatively less code, depending on your personal habits.
Vue judges to click on the current element
Click the button, the pop-up window appears; then click the mask layer, and the current pop-up window disappears.
Click events are initially bound to the mask layer, but if you click on the form form, the current pop-up window disappears.
You need to determine whether you clicked on the mask layer or the form form.
1. Bind the click event @ click= "showfun2 ($event)" on the mask layer
two。 Determine whether the current element e.currentTarget = = e.target has been clicked
Showfun2 (e) {if (e.currentTarget = e.target) {this.msg = false}}
The above completes the judgment of the click element of the current event.
The next step is to print showfun2 (e) {console.log (e.currentTarget) console.log (e.target)} for e.currentTarget and e.target respectively.
Click the mask layer for the first time
Click on the form form the second time
It is found that what e.currentTarget prints is always the element that binds the click event.
This is the end of the content of "vue how to judge whether the button can be clicked according to the conditions". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.