zoukankan      html  css  js  c++  java
  • 小程序在js里获取控件的两种方式

    一种用 点+控件类名

    var query = wx.createSelectorQuery();
        //选择id
        var that = this;
        query.select('.progressBarCarrier').boundingClientRect(function (rect) {
          let width = rect.width
          console.log("矩形:" + JSON.stringify(rect))
          let setpWidth = width / 25
          // console.log("空你感觉:" + setpWidth)
          that.setData({
            stepWidth: setpWidth
          })
        }).exec();

    另外一种用 #+控件id

            let option = answers[idx]
            let optionName = "#opt" + bigIdx+idx
           
            var query = wx.createSelectorQuery();
            //选择id
            var that = this;
            query.select(optionName).boundingClientRect(function (rect) {
              let height = rect.height
              console.log("选项尺寸:" + JSON.stringify(rect))
    
              option.borderRadius = height
              console.log("选项字典:" + JSON.stringify(questions))
              that.setData({
                questionList: questions
              })
            }).exec();
  • 相关阅读:
    4.单例模式
    3.适配器模式
    2.策略模式
    1.工厂模式
    机器学习
    何为技术领导力
    图像像素的算术操作
    图像对象创建和赋值的区别
    图像色彩空间转换
    notepad更改文档编码格式
  • 原文地址:https://www.cnblogs.com/tufei7/p/12530102.html
Copyright © 2011-2022 走看看