[Bug Report] packs element-ui collapse-transition using webpack and fails
Element UI version
1.4.3
OS/Browsers version
all
Vue version
2.4.2
Reproduction Link
https://jsfiddle.net/pj71jkyw/
Steps to reproduce
-
引入 import ElementUI from 'element-ui/src/index
-
webpack 版本 2.2.1 vue 版本 2.4.2
-
.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" ] } } },
-
进入源码 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失效
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
-
introduce import ElementUI from'element-ui/src/index
-
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"] }
} },
- 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
Issues without a reproduction link will be closed directly.
就直接关了?
原因是打包造成的,可能会出现在“魔改” 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) {}