对于自定义事件最需要了解的一点是,您的代码必须导致这些事件发生。这些事件不会为响应用户或系统的动作而自动发生,即使能够编写导致事件确实以这种方式发生的代码也不例外。包含自定义事件的类模块还必须包括一个唤起事件的公有方法。这个方法通过调用 RaiseEvent 语句并传入为事件定义的任何参数来唤起事件。这些参数按顺序传入为响应事件而运行的事件过程中。
你如何调度和听在聚合物中的自定义事件?
How do you dispatch and listen for custom events in Polymer?
除了清除面板之外,其主要作用还有通过自定义事件处理程序可选择性地执行业务规则。
The key purpose, besides the obvious clearing of the panel, is to optionally enforce business rules with the custom event handlers.
用户可以毫不费力地创建出自己的作用域和自定义事件(比如web请求的作用域)。
Users can easily create their own scopes and set up custom events (e.g. a web request scope).
应用推荐