element icon indicating copy to clipboard operation
element copied to clipboard

[Bug Report] packs element-ui collapse-transition using webpack and fails

Open idujiayou opened this issue 9 years ago • 4 comments

Element UI version

1.4.3

OS/Browsers version

all

Vue version

2.4.2

Reproduction Link

https://jsfiddle.net/pj71jkyw/

Steps to reproduce

  1. 引入 import ElementUI from 'element-ui/src/index

  2. webpack 版本 2.2.1 vue 版本 2.4.2

  3. .babelrc { "presets": [ ["env", { "modules": false }], "stage-2", "es2015", "flow-vue" ], "plugins": ["transform-runtime", "transform-vue-jsx", "transform-flow-strip-types"], "comments": false, "env": { "test": { "presets": ["env", "stage-2"], "plugins": [ "istanbul" ] } } },

  4. 进入源码 src/transitions/collapse-transition 调试下面代码 发现Transition的方法都行挂在prototype下面 无法枚举 导致h('transition', data, children); 中on无法获取对应方法 export default { name: 'ElCollapseTransition', functional: true, render(h, { children }) { const data = { on: new Transition() };

    return h('transition', data, children); } };

What is Expected?

在使用webpack打包下 collapse-transition能正常执行

What is actually happening?

collapse-transition失效

idujiayou avatar Sep 01 '17 03:09 idujiayou

Translation of this issue:

Element UI version

1.4.3

OS/Browsers version

All

Vue version

2.4.2

Reproduction Link

https://jsfiddle.net/pj71jkyw/

Steps to reproduce

  1. introduce import ElementUI from'element-ui/src/index

  2. webpack version, 2.2.1 Vue version, 2.4.2 3..Babelrc

{ "Presets":

["env", {"modules": false}], "Stage-2."",

"Es2015."", "Flow-vue.""

], "Plugins": ["transform-runtime", "transform-vue-jsx", "transform-flow-strip-types"],

"Comments": false, "Env": {

"Test": { "Presets": ["env", "stage-2"],

"Plugins": ["Istanbul"] }

} },

  1. enter the source code below. Transition src/transitions/collapse-transition debugging method found hanging in the following prototype cannot be enumerated lead to h ('transition', data, children); the corresponding method to get the on to Export default {

Name:'ElCollapseTransition', Functional: true,

Render (h, {children}) { Const data = {

On:, new, Transition () };

Return, H ('transition', data, children); }

};

What is Expected?

Collapse-transition can execute normally when packaged using webpack

What is actually happening?

Collapse-transition failure

element-bot avatar Sep 01 '17 03:09 element-bot

Issues without a reproduction link will be closed directly.

Leopoldthecoder avatar Sep 01 '17 03:09 Leopoldthecoder

就直接关了?

xianghongai avatar Dec 09 '20 06:12 xianghongai

原因是打包造成的,可能会出现在“魔改” Element UI 的场景中。 将 Class 语法改成 Prototype 语法,能“暂时”修复这个问题。

function Transition() {}

Transition.prototype.beforeEnter = function(el) {}

Transition.prototype.enter = function(el) {}

Transition.prototype.afterEnter = function(el) {}

Transition.prototype.beforeLeave = function(el) {}

Transition.prototype.leave = function(el) {}

Transition.prototype.afterLeave = function(el) {}

xianghongai avatar Dec 09 '20 08:12 xianghongai