In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to use the computed calculation attribute of Vue". In the daily operation, I believe that many people have doubts about how to use the computed calculation attribute of Vue. The editor consulted all kinds of data and sorted out a simple and easy-to-use method of operation. I hope it will be helpful to answer the doubt of "how to use the computed calculation attribute of Vue". Next, please follow the editor to study!
Computed calculation attribute 1. What is a calculation attribute
Computed attributes are essentially methods, but when using these computed properties, their names are used directly as attributes, and they are not called as methods, and do not need to be called with parentheses ().
2. Why do you use computational attributes
When you need an attribute, you need to go through some calculations, such as you want a discounted discount after the money attribute, there are now price prices, and discount discounts. So, discounted=price*discount. Discounted is associated with the existing properties price and discount.
To get the value of discounted, we can write like this.
{{price*discount}}
Don't we want the discounted attribute? it seems that there is no need to add an attribute in this way, just use the expression to calculate the discounted value.
So, if we have to get a discounted, we might think of using methods to write a method for calculation.
Original price:
Current price: data () {return {price:100, discount:0.8}}, methods: {discounted () {this.price*discount}}
Take a look at the comunidad calculation properties of vue.
Original price:
Current price: computed: {discounted () {return this.price*this.discount}}
And we wonder, isn't it possible to get discounted by using the expression price*discount, and why bother to write the method, computed?
So the problem is, if our discounted is based on the amount of money you buy, follow the rules:
Original price x discount 0
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.