An import declaration can only be used at the top level of a namespace or module:导入声明只能在命名空间或模块的顶层使用

vue项目在编译的时候,报了这样的错误:

原因很简单,竟然是因为我把import放在了不是最顶部的位置: 

应该将这个放到const变量定义之前就可以了: 

然后就编译成功了:

猜你喜欢

转载自blog.csdn.net/weixin_44786530/article/details/131203629