小程序之个人总结

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.获取用户信息

    /**
     * 获取用户信息
     */
    // 老版本:getUserInfo
    wx.getUserInfo({
   
      success: function (res) 
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值