【小程序】踩坑记录
2018-10-11
- WePY 1.x 版本中,组件使用的是静态编译组件,即组件是在编译阶段编译进页面的,每个组件都是唯一的一个实例,目前只提供简单的 repeat 支持。不支持在 repeat 的组件中去使用 props, computed, watch 等等特性。
参考: https://tencent.github.io/wepy/document.html#/?id=存在的问题- 子元素继承父元素透明度解决: 父元素 background: rgba(0,0,0,0.7)
- 事件传递从内向外,由子元素传向父元素(和Android中事件传递相反),默认事件冒泡,可通过@tap.stop 拦截
- 相对布局实现:父布局:position: relative; 子布局: position: absolute
- 组件 components 中 data 内的字段可**直接通过 {{字段名}}**使用,不需 this.
2018-10-24
wepy使用mixin混合,onload事件响应:
打印日志证明:先执行混合对象的onLoad页面事件,再执行组件本身的onLoad事件。
经过试验,onLoad事件的回调,和组件中声名
mixins = [ mixin1, mixin2]
的顺序有关,在前的先执行,依次执行完毕后,才会执行组件自身的onLoad回调。
已提到小程序社区,待解答
https://developers.weixin.qq.com/community/develop/doc/0004e0659e8f60d4ff872012456000
小程序码参数解析:
小程序开发工具,选择通过二维码编译;
在App.onShow(options)中打印参数如下:
{"path":"custom/package/package","query":{"scene":"210561493!12345"},"scene":1047,"referrerInfo":{}}
在Page.onLoad(options)中打印参数如下:
onload--options:{"scene":"210561493!12345"}
// 注意scene最大长度为32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~
解析参数:
onLoad:function(options){
if(options.scene){
let scene=decodeURIComponent(options.scene);
let productId=options.scene.split("!")[0]; // ! 数据分割符
let p=options.scene.split('!')[1];
}
}
即:把"query"的值作为参数传到onLoad()方法中