VM115148 vue.esm.js:1896 Error: [ElementForm]unpected width at VueComponent.getLabelWidthIndex

e4eetjau  于 3个月前  发布在  其他
关注(0)|答案(1)|浏览(47)

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch element-ui@2.15.7 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/element-ui/packages/form/src/label-wrap.vue b/node_modules/element-ui/packages/form/src/label-wrap.vue
index d263f7d..a59023a 100644
--- a/node_modules/element-ui/packages/form/src/label-wrap.vue
+++ b/node_modules/element-ui/packages/form/src/label-wrap.vue
@@ -32,7 +32,8 @@ export default {
     getLabelWidth() {
       if (this.$el && this.$el.firstElementChild) {
         const computedWidth = window.getComputedStyle(this.$el.firstElementChild).width;
-        return Math.ceil(parseFloat(computedWidth));
+        return Math.ceil(parseFloat(computedWidth) || 0);
       } else {
         return 0;
       }

This issue body was partially generated by patch-package .

r55awzrz

r55awzrz1#

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch element-ui@2.15.7 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/element-ui/packages/form/src/label-wrap.vue b/node_modules/element-ui/packages/form/src/label-wrap.vue
index d263f7d..a59023a 100644
--- a/node_modules/element-ui/packages/form/src/label-wrap.vue
+++ b/node_modules/element-ui/packages/form/src/label-wrap.vue
@@ -32,7 +32,8 @@ export default {
     getLabelWidth() {
       if (this.$el && this.$el.firstElementChild) {
         const computedWidth = window.getComputedStyle(this.$el.firstElementChild).width;
-        return Math.ceil(parseFloat(computedWidth));
+        return Math.ceil(parseFloat(computedWidth) || 0);
       } else {
         return 0;
       }

This issue body was partially generated by patch-package .

First of all, thank you for your work.I found that your update did not solve this problem (#Error: [ElementForm]unpected width at VueComponent.getLabelWidthIndex), I solved it with the following changes, at least in my project it works well

// node_modules/element-ui/lib/form-item.js
-  return Math.ceil(parseFloat(computedWidth));
+ return Math.ceil(parseFloat(computedWidth) || 0);

Welcome to communicate👏👏👏!

相关问题