常用代码块

1: 文字超出显示省略号

1)如果容器有固定宽度

view {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

2)如果容器没有固定的宽度

view {
  display: -webkit-box;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-all;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}
2: 去除按钮边框
.contact_item {
    margin: 20rpx;
    font-size: 10pt;
    background: none !important;
}
.contact_item::after{
  border: none;
}
3: 自定义Toast图标
wx.showToast({
    image: "/images/余额.png",
    title: '录音时间太短',
})
4: 选取本地照片显示在image中
<image style="width: 200px; height: 200px; background-color: #eeeeee;" mode="{{mode}}" src="{{src}}" bindtap='imgtap'></image>

  setimg:function(){
    var _this =this
    wx.chooseImage({
      count: 1, // 默认9
      sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
      sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
      success: function (res) {
        // 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片
        var tempFilePaths = res.tempFilePaths
        _this.setData({
          src: tempFilePaths
        })
        //this.src=tempFilePaths

      }
    })
  }
5: 调用扫码
<button type="default" size="mini" bindtap="setcode">扫码 </button>
  setcode:function(){
    wx.scanCode({
      onlyFromCamera: true,
      success: (res) => {
        console.log(res)
      }
    })
  }
5: 深拷贝

JSON.parse(JSON.stringify(this.QueryParams))

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容