element-plus: h render method can not use ElButton component
as the title
import { ElButton } from 'element-plus';
...
render() {
return h(ELButton,{}, 'test');
}
expect: button with test text actual: Uncaught (in promise) ReferenceError: ElButton is not defined
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 18 (11 by maintainers)
So I can confirm that this was cause by
babel-component-loaderbecause it importelement-plus/lib/el-button/index.js, see the screenshot below. And because that this file was built incjsformat.Because of that this is not a harmony export member A.K.A. it is not a ESModule, webpack goes to this:
then we resolve this code:
h(getter, {}, []); // getter is what we got resolved by webpack.Here’s how to solve that temporarily: Assigning it to a variable, then the getter gets called, you get the actual component.