Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

第68题:vue中computed 和 watch 的区别在哪里? #68

Open
noxussj opened this issue Jun 18, 2020 · 0 comments
Open

第68题:vue中computed 和 watch 的区别在哪里? #68

noxussj opened this issue Jun 18, 2020 · 0 comments
Labels

Comments

@noxussj
Copy link
Owner

noxussj commented Jun 18, 2020

watch监听属性

主要用于监听数据发生变化,可以监听的来源有props、data、computed。
watch方法接受2个参数(newValue,oldValue),第一个参数是发生变化后的值,第二个参数是发生变化前的值

computed计算属性

computed主要是存储一些需要数据处理的值,其实和data比较像,也可以理解为在data的基础上做一些额外的数据处理操作,并且返回一个新的变量。
假设computed方法内使用了data的变量,当data变量发生改变后,则会触发当前computed变量进行重新计算

@noxussj noxussj added the Vue label Jun 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant