1.1.1
ant-design-vue: 1.1.1; babel-plugin-import: 1.9.1; vue: 2.5.2
https://git.coding.net/wangye84/vue-antd-admin-template.git
when i import ant-design-vue and babel-plugin-import follow API guide's to :
// in main.js
import Antd from 'ant-design-vue'
import 'ant-design-vue/dist/antd.css'
Vue.use(Antd)
// in .babelrc
{
"presets": [
["env", {
"modules": false,
"targets": {
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
}
}],
"stage-2"
],
"plugins": [
"transform-vue-jsx",
[
"import",
{
"libraryName": "ant-design-vue",
"libraryDirectory": "lib",
"style": true
}
],
"transform-runtime"
],
"env": {
"test": {
"presets": ["env"],
"plugins": [
"transform-vue-jsx",
"transform-es2015-modules-commonjs",
"dynamic-import-node",
"transform-runtime"
]
}
}
}
my web will be display
in browser's console, i saw the : Antd is not defined
branch : importAntd
import Antd from 'ant-design-vue' and babel-plugin-import cannot be used together.
If you want to use babel-plugin-import, you should use it like this:
import { Button } from 'ant-design-vue'
@tangjinzhou And other question, if i use what you said's way, i will not declare antd in main.js ,right? so, i import component
you should use it like this in main.js
import Vue from 'vue'
import { Button, message } from 'ant-design-vue'
import App from './App'
Vue.config.productionTip = false
Vue.component(Button.name, Button)
Vue.prototype.$message = message
/* eslint-disable no-new */
new Vue({
el: '#app',
components: { App },
template: '<App/>'
})
More components in here
@tangjinzhou I just fixed this problem with import my component in .vue file and use const { Item } = Menu, I was do this but without statement it in components what leaded to up question
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
import Antd from 'ant-design-vue'andbabel-plugin-importcannot be used together.If you want to use
babel-plugin-import, you should use it like this:import { Button } from 'ant-design-vue'