Vue获取动态样式的宽度
用vue 获取动态元素的宽度。首页,要放在this.$nextTick里面,其实要使用$el挂载此元素,下面贴代码<el-input auto-complete="off" v-model="company.companyName" ref="companyStyle"></el-input&am
·
用vue 获取动态元素的宽度。首页,要放在this.$nextTick里面,其实要使用$el挂载此元素,下面贴代码
<el-input auto-complete="off" v-model="company.companyName" ref="companyStyle"></el-input>
先定义一个ref=companyStyle,我们来获取此元素的宽度,
newAddBtn(){
let me = this;
this.$nextTick(function () {
me.inputStyWidth = me.$refs.companyStyle.$el.clientWidth + 'px';
})
这样我们就获取到了这个元素的宽度了更多推荐
已为社区贡献28条内容
所有评论(0)