uniapp获得控件宽度(H5、小程序)
时间:2020-09-26 18:36:56
收藏:0
阅读:148
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()
原文:https://www.cnblogs.com/lkpp/p/13734984.html
评论(0)