[ElementForm]unpected width at VueComponent.getLabelWidthIndex

内容纲要

image.png
猛地一看,以为是在destroy方法里写的代码有问题,可是我的vue文件里面我没有手动的去写destroy方法。

vue.esm.js:1897 Error: [ElementForm]unpected width 
    at VueComponent.getLabelWidthIndex (element-ui.common.js:23014)
    at VueComponent.deregisterLabelWidth (element-ui.common.js:23027)
    at VueComponent.updateLabelWidth (element-ui.common.js:23226)
    at VueComponent.beforeDestroy (element-ui.common.js:23253)
    at invokeWithErrorHandling (vue.esm.js:1863)
    at callHook (vue.esm.js:4222)
    at VueComponent.Vue.$destroy (vue.esm.js:3981)
    at destroy (vue.esm.js:3168)
    at invokeDestroyHook (vue.esm.js:6119)
    at invokeDestroyHook (vue.esm.js:6124)

解决办法

造成这个错误的原因是当组件中存在v-show时,并且el-form中labelWidth设为auto时,就会获取不到label的宽度。可以将v-show的地方改为v-if,每次重新渲染组件,或是labelWidth设为固定。

image.png

改成这样就好了

image.png

标签