Skip to content
New issue

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

nuxt按需引入得到Cannot use import statement outside a module #2022

Closed
1 task
bosens-China opened this issue Apr 4, 2020 · 4 comments
Closed
1 task
Labels

Comments

@bosens-China
Copy link

  • I have searched the issues of this repository and believe that this is not a duplicate.

Version

1.5.1

Environment

win10,chrome80 vue 2.6

Reproduction link

https://ant-design-vue.gitee.io/issue-helper/暂无

Steps to reproduce

使用官方脚手架拉取模板,修改nuxt.config.js文件,添加plugins>ant-design-vue.js报错Cannot use import statement outside a module,全局引入是没有问题的,这个让我很费解。

ant-design-vue.js

// 按需加载组件
import Vue from 'vue'
import { Menu, Icon, ConfigProvider, Layout } from 'ant-design-vue'

Vue.use(Menu)

Vue.use(Icon)
Vue.use(ConfigProvider)
Vue.use(Layout)

nuxt.config.js

css: [
{ src: 'ant-design-vue/dist/antd.less', lang: 'less' },
'@/assets/style.less'
],
// ...
build: {
babel: {
plugins: [['import', { libraryName: 'ant-design-vue', style: 'css' }]]
},
loaders: {
less: {
javascriptEnabled: true
}
}
},

What is expected?

期待正常按需加载

What is actually happening?

Cannot use import statement outside a module

@bosens-China
Copy link
Author

抱歉,链接地址就没添加,不过剪短的说明,应该足够了

@tangjinzhou
Copy link
Member

#234 (comment)

@bosens-China
Copy link
Author

@tangjinzhou
谢谢,我晚上尝试下,可以方便问下关于ico组件,有一个加载阿里图标库的实例,我如果用nuxt这部分是不是不能让他在服务器渲染中呈现

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants