基本上,computed能实现的功能watch都能实现
computed里计算属性是通过return返回的,无法实现异步,如setTimeout()
computed: {
fullName() {
setTimeout(() => {
return this.firstName + this.lastName // 这里的return返回到的是() => {}函数,fullName没有返回值
}, 1000);
}
基本上,computed能实现的功能watch都能实现
computed里计算属性是通过return返回的,无法实现异步,如setTimeout()
computed: {
fullName() {
setTimeout(() => {
return this.firstName + this.lastName // 这里的return返回到的是() => {}函数,fullName没有返回值
}, 1000);
}