usage
The child component dispatches messages to the upper layer of the component tree via the dispatch method.
1 | class Son extends san.Component { |
The message will be passed up the component tree until it encounters the first component that processes the message. Use messages to declare the message the component will process. messages is an object, the key is the name of a message, and value is the processing function of a message, which receives an object parameter containing target
(the component that dispatches the message) and value
(the value of the message).
1 | class GrandParent extends san.Component { |
examples
See the Pen higher-communication by Swan (@jiangjiu8357) on CodePen.