An import declaration can only be used at the top level of a namespace or module: Import declarations can only be used at the top level of a namespace or module

When compiling the vue project, such an error was reported:

The reason is very simple, it turned out to be because I put the import not at the top: 

You should put this before the const variable definition: 

Then it compiles successfully:

Guess you like

Origin blog.csdn.net/weixin_44786530/article/details/131203629