H5端获得控件的宽度
// #ifdef H5
let width= this.$el.querySelector('.btn').clientWidth;				
// #endif

微信小程序获得控件的宽度
// #ifdef MP
let width= 0;
				
var query = this.createSelectorQuery();
query.select('.btn').boundingClientRect(
      function(rect){
            if(rect.width){
                  width=rect.width;	
	      }
	}
      ).exec();								
// #endif

参考链接:SelectorQuery wx.createSelectorQuery()

相关文章:

  • 2023-03-11
  • 2022-01-07
  • 2022-01-07
  • 2022-12-23
  • 2022-12-23
  • 2022-01-08
  • 2021-09-22
猜你喜欢
  • 2021-12-22
  • 2022-12-23
  • 2021-12-11
  • 2022-01-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案