常用方法:
watch监听数据完成后执行函数;
watch: {
huxing: {
handler: function(newVal, oldVal) {
this.huxingW();
},
deep: true,
immediate: true
}
}
methods: {
huxingW() {
this.$nextTick(function() {
let len = this.$refs.ul.children.length;
if (len > 0) {
let liw = this.$refs.ul.children[0].offsetWidth;
this.widthnum = liw * len + 5 + "px";
}
});
}
},
其他链接: