便捷方法

// 文字超出省略(多行)
overflow: hidden;
word-break: break-all;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 1;

// 文字超出省略(單行)
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;

// 獲取元素高度
let that = this;
setTimeout(() => {
    let query = wx.createSelectorQuery();
    query.select('.box').boundingClientRect(rect=>{
        that.setData({
            height:  rect.height
        });
      }).exec();
}, 100);

// 調(diào)取子元素方法
this.selectComponent('.shopping').switch_fun();

// 點(diǎn)擊上傳圖片
upload_image(){
    const that = this;
    wx.showActionSheet({
      itemList: ['從相冊中選擇', '拍照'],
      itemColor: "#f7982a",
      success: function (res) {
        if (!res.cancel) {
          if (res.tapIndex == 0) {
            that.chooseWxImageShop('album');//從相冊中選擇
          } else if (res.tapIndex == 1) {
            that.chooseWxImageShop('camera');//手機(jī)拍照
          }
        }
      }
    })
  },
  // 選擇圖片
  chooseWxImageShop: function (type) {
    var that = this;
    // 選擇圖片api或者拍照
    wx.chooseImage({
      sizeType: ['original', 'compressed'],
      sourceType: [type],
      success: async function (photo) {
        let images = that.data.img;
        let images_load = that.data.show_img;
        photo.tempFilePaths.forEach(ele => {
          const thumb = wx.getFileSystemManager().readFileSync(ele, 'base64');
          images_load.push(thumb);
          images.push(ele);
        });
        that.setData({
          img: images,
          show_img: images_load
        });
      }
    })
  },

// 獲取頁面參數(shù)
let pages = getCurrentPages() // 獲取加載的頁面
let currentPage = pages[pages.length - 1] // 獲取當(dāng)前頁面的對象
let url = currentPage.route // 當(dāng)前頁面url
let options = currentPage.options // 如果要獲取url中所帶的參數(shù)可以查看options
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容