1.小程序数据同步
this.setData({
属性名:值 或 '对象.属性名':值
})
var str = `noticeListList[${
index}].readStatus`
this.setData({
[str]: "1"
})
2.跳转到非tabBar页面
wx.navigateTo({
url: '/pages/customerDetails/customerDetails',
})
3.图片
image:添加mode="widthFix" width给定死
4.获取参数
<view class="line {
{item.readStatus=='0'? 'unread':''}}" bindtap="detailnoticeList" data-announceForm="{
{item.announceForm}}">
函数:
detailnoticeList(even){
var announceForm = even.currentTarget.dataset.announceform
console.log(announceForm)
wx.navigateTo({
url: `/pages/noticeDetailImg/noticeDetailImg?announceForm=${
announceForm}`,
})
},
5.文字一行显示
overflow:hidden;
text-overflow:ellipsis;
white-space:nowrap;
width:88%;
6.页面可进行分享或不允许分享
允许分享:
如果想不允许右上角转发分享当前页面,又想在页面里点击按钮分享并且自定义分享的 title 和 imgUrl 呢
可以在onLoad里写
this.onShareAppMessage = (e)=>{
return {
title:'xxxxxxxxxxxx',
path:'/pages/xxxx/xxxx',
imgUrl:'xxxxxxxxxxxxxxxxxxx'
}
}
在页面wxml里写 <button open-type="share">分享button> 即可
不允许分享:
onShareAppMessage
方法删除即可!
7.获取数组中对应id的对象或索引值
var index = this.data.noticeListList.findIndex(item => item.announceId == even.currentTarget.dataset.announceid)
var index = this.data.noticeListList.find(item => item.announceId == even.currentTarget.dataset.announceid)
8.获取用户信息
wx.getUserInfo({
success: function (res)