亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

javascript - Ask about the applicable scenarios of vue.js methods and computed! !
ringa_lee
ringa_lee 2017-06-24 09:43:59
0
4
888

I’ve been a little confused lately. I don’t know when to use which of the two? ? Request for advice

ringa_lee
ringa_lee

ringa_lee

reply all(4)
洪濤

1.computed is used when you want to monitor changes in data. When the monitored data changes, the calculation will be performed immediately and the result will be returned.
2.methods only defines functions. If you want to execute it, you have to execute it manually!

淡淡煙草味

methods is generally used to define ordinary functions, computed is used if you need to do some calculations when your data changes

巴扎黑

Computed Properties-vs-Methods

1. Computed attributes are cached based on attribute dependencies. Computed attributes will only be re-evaluated when their related dependencies change
When the attribute value does not change, the evaluation will immediately return the previous result, while methods need to be re-calculated, so the evaluation of attributes with dependencies needs to be cached Use computed, use methods if not cached
2. Use methods if there are no attribute dependencies

黃舟

computed will monitor changes, evaluation, method, if you want to call, write HTML trigger method, such as inputchange event, and computed can monitor changes for a certain field

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template