Skip to content

Vue动态监听,computed与watch的取舍 #23

@heightzhang

Description

@heightzhang

computed
watch

watch用于观察属性发送变化后,做额外处理。
与computed属性的差别在于作用对象不同,watch观察变化的源头,而computed属性是变化的目标,当然,两者可以互相转换。两者如何取舍在于:变化的源与目标哪部分的属性更多,如果多个源属性变化影响一个目标属性则建议使用computed;相反,如一个源属性变化影响了多个目标属性,则建议采用watch。

参考来源:Vue相关属性总结

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions