ElemeFE / element

A Vue.js 2.0 UI Toolkit for Web
https://element.eleme.io/
MIT License
54.12k stars 14.65k forks source link

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

Open Frank-zf opened 1 year ago

Frank-zf commented 1 year ago

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.

OFreshman commented 4 months ago

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๐Ÿ‘๐Ÿ‘๐Ÿ‘๏ผ