ElementUI / babel-plugin-component

Modular element-ui build plugin for babel.
452 stars 96 forks source link

ImportSpecifier 中 有local Identifier的时候报错 #33

Open dcy0701 opened 6 years ago

dcy0701 commented 6 years ago
import { Container as ElContainer } from 'element-ui'

这样会报错,这样对于JSX单文件组件或者class-component 很不方便。

需要多写Vue的组件注册(其实完全可以省掉)

Vue.component(Container.name, Container);

或者比如现在的形式,需要在components中alias一下。

import { Container, Main, Button, Header } from 'element-ui'
import template from './app.vue'

@Component({
    name: 'page-app',
    mixins: [template],
    components: {
        ElContainer: Container
    }
})
export default class App extends Vue {

}

或者单文件组件

import { Container, Main, Button, Header } from 'element-ui'
const ElContainer = Container 
@Component({
    name: 'page-app'
})
export default class App extends Vue {
   render () {
       <ElContainer/>
  }
}

极其不方便。

FlorianWendelborn commented 2 years ago

Seems to be fixed in the original repo by this PR https://github.com/umijs/babel-plugin-import/pull/137