watch
与export default
>在Vue中进行export default
>中导出vue component并不会影响watch
>选项的功能或语法。 无论您使用watch
>还是命名的导出,export default
>选项的工作原理完全相同。 export default
语法只是从文件中导出单个默认组件的一种便捷方法。
watch
>export default
> watch
watch: { myObject: { handler: function (newValue, oldValue) { // ... }, deep: true // this is expensive! } }
watch: { 'myObject.propertyA': { handler: function (newValue, oldValue) { // ... } }, 'myObject.propertyB': { handler: function (newValue, oldValue) { // ... } } }
deep
deep
>考虑:immediate
watch
watch
> <> <> <> watch
debouncing/throttling的工作:
watch
watch
彻底测试您的watch
<🎜和每个处理程序的行为,以帮助理解和维护。>以下是一个示例演示最佳实践的示例:
watch: { myObject: { handler: function (newValue, oldValue) { // ... }, deep: true // this is expensive! } }
export default
?>?>?>?>?>?>?> watch
no的功能或偶像性,使用export default
>选项都相同工作。 出口方法的选择纯粹是一种风格或组织偏好。 watch
配置保持一致。watch
以上是Vue中export default如何配置组件的watch的详细内容。更多信息请关注PHP中文网其他相关文章!