We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
按照文档安装babel-plugin-import。
在babel.config.js中做如下设置
module.exports = { presets: [ '@vue/cli-plugin-babel/preset', ], plugins: [ [ 'import', { libraryName: 'ant-design-vue', libraryDirectory: 'es', style: 'css', }, ], // `style: true` 会加载 less 文件 ], };
然后引入文件:
import Vue from 'vue'; import { Button } from 'ant-design-vue'; Vue.use(Button);
ant-design-vue使用了moment这个库,moment这个库默认打包了所有的语言包,但实际上我们只需要中文。
在vue.config.js中
configureWebpack (config) { // 干掉语言包 config.plugins.push(new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/)); },
然后我们需要在main.js或者App.vue中
// 引入中文语言包 import moment from 'moment'; import 'moment/locale/zh-cn'; moment.locale('zh-cn');
引入Icon组件后,所有的icon图表都会被打包,但是我们的场景下用到的icon只有那几个。
configureWebpack (config) { config.resolve.alias['@ant-design/icons/lib/dist$'] = path.join(__dirname, 'src/icons.js'); },
这样解析icon文件,就不在node_modules/@ant-design/icons/lib/下查找,而是在icons.js中查找。
在icons.js文件中,我们手动引入需要的icon
export { default as RightOutline, } from '@ant-design/icons/lib/outline/RightOutline'; export { default as CheckCircleFill, } from '@ant-design/icons/lib/fill/CheckCircleFill';
注意这么做会把其他组件(如message、confirm)用到的icon也干掉,需要手动检查一遍。
The text was updated successfully, but these errors were encountered:
No branches or pull requests
按需加载
按照文档安装babel-plugin-import。
在babel.config.js中做如下设置
然后引入文件:
moment
ant-design-vue使用了moment这个库,moment这个库默认打包了所有的语言包,但实际上我们只需要中文。
在vue.config.js中
然后我们需要在main.js或者App.vue中
icon
引入Icon组件后,所有的icon图表都会被打包,但是我们的场景下用到的icon只有那几个。
在vue.config.js中
这样解析icon文件,就不在node_modules/@ant-design/icons/lib/下查找,而是在icons.js中查找。
在icons.js文件中,我们手动引入需要的icon
注意这么做会把其他组件(如message、confirm)用到的icon也干掉,需要手动检查一遍。
The text was updated successfully, but these errors were encountered: