-
Notifications
You must be signed in to change notification settings - Fork 81
-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MIP 页面事件 event-action 讨论 #228
Comments
额,发现在 pc 使用模拟器还是可以复现的。因为模拟器里有 |
复议,我也遇到类似问题。 使用场景:将弹层(mip-lightbox)组件与mip-form表单共同使用,接收用户输入。当mip-form提交时获取输入内容,触发弹层显示,将内容显示在弹层中。 遇到的问题我写了个性化组件来读取用户输入,当用户点击回车,在弹层中显示输入内容。但在个性化组件中不能触发触发弹层内部暴露出来的open事件。 建议将customElement和对应DOM绑定,通过DOM能获取customElement 属性及公共方法。提供触发组件公共方法的函数,如MIP.trigger(querySelector('#lightbox'), 'open')。 |
并且梳理下现在使用的事件,比如:
|
还有,事件这块能不能实现一些通用的方法,如:跳转链接 |
尴尬,天天被这问题坑。 |
像这种,可以使用组件内部逻辑进行点击影藏,而不是使用 tap |
在外部 tapbar 上加一个元素点击时显示 sidebar ,而 sidebar 里会有链接。 |
关联 mipengine/mip-extensions#986 ,也需要考虑 |
贴一个站长日常提交的组件日常。 /**
* @file
* @author
* @version 1.0.0
*/
define(function (require) {
var customElement = require('customElement').create();
var util = require('util');
/**
* build
*
*/
function build() {
var that = this;
that.addEventAction('close', function (event) {
event.preventDefault();
util.css(that.element, 'display', 'none');
});
}
customElement.prototype.build = build;
return customElement;
}); |
添加了 |
遵循 MIP 规范,页面元素使用 event-action 形式,如:
<div on="tap:test.custom_event">不带参数</div>
(文档),但由于是tap
事件,如果应用于一些事件里会覆盖触发元素的场景(如:弹出层),就会发生点击穿透,场景如:在页面中
<button on="tap:right-sidebar.open">
点击按钮时让一个 sidebar 显示,而这个 sidebar 是个弹层,弹层中又有一些跳转链接,导致点击时先触发弹层显示,又直接跳转了页面。本身想使用
on="click:right-sidebar.open"
解决,但没有该接口。而tap
事件在 pc 中又是由click
替换,从而在 pc 中又复现不了。via:
mip/src/viewer.js
Lines 122 to 136 in 8426f65
The text was updated successfully, but these errors were encountered: