element 按需引用
# element 按需引用
安装
npm install babel-plugin-component -D
1
然后,将 .babelrc 修改为:
{
"presets": [["es2015", { "modules": false }]],
"plugins": [
[
"component",
{
"libraryName": "element-ui",
"styleLibraryName": "theme-chalk"
}
]
]
}
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
按组件引用
import { Button, Select } from 'element-ui';
Vue.component(Button.name, Button);
Vue.component(Select.name, Select);
1
2
3
4
2
3
4
编辑 (opens new window)
上次更新: 2023/12/06, 01:31:48