Files
heros/doc/mvvm/VMParent.md

24 lines
933 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## VM Parent
### 介绍
如果你想要让你的组件具有 动态监听数据的能力,需要继承 VMParent 使用。监听的数据类型为组件实例自身所有,是局部的数据而非全局数据。
### 属性
`data` - 定义需要绑定的数据类型,只在该组件内有效。定义后,这些数据就会被自动绑定。
`onBind()` - 数据绑定完成后调用该方法
`onUnBind()` - 数据绑定解除之前调用该方法
`tag` - 绑定的标签可以通过这个tag 获取 当前的 vm 实例
`VM` - VM 管理对象,可以使用该对象获取值路径
### 注意事项
- 如果你不清楚继承机制,不要随意覆盖 onLoad() 事件,请使用 onBind() 函数代替 onLoad() 函数, onUnBind() 函数代替 onDestroy() 函数。如果你熟悉可以使用super.onLoad() 的方式 调用父方法
- 不要过多的嵌套使用VMParent, 在绑定时可能会影响一点性能