1. 小程序canvas那些原生组件的层级默认是最高的,而且不能更改,平常的div弹框什么的上面就会显示出原生组件的内容,
解决办法:cover-view,cover-image,button
2. 小程序分享,写的时候是用mpvue框架,分享的按钮是在子组件里面,配套使用的onShareAppMessage函数当时也写在了子组件里面,然后就报错,“apply of null”什么的,
原因是这个onShareAppMessage函数只能写在page页面里面,不能写在子组件中,然后写在父组件里面就要给这个函数传值,传值方法如下:
<button open-type="share" :data-item="item" >分享</button>
用这个data-item , "-"后的名字可以随意起,后面的值如果是字符串数字什么的,就可以直接写data-item,不用写“:”
传过值之后onShareAppMessage要取出这个值,取值方法如下:
onShareAppMessage: function(ops) { let item = ops.target.dataset.item; let url = "/" + item.share_page; let share_image = item.share_image return { title: item.title, path: url, imageUrl: share_image };
},
3. 小程序中div都有默认样式line-height,实现设计图时就会有对不上间距的时候,解决方法
line-height: 1;
小程序中img有默认样式display:inline-block;有时就算用了flex也有隐藏的边距,所以解决方法就是让img的display改为block