Vue - Cannot use import statement outside a module

后端 未结 3 3107
伪装坚强ぢ
伪装坚强ぢ 2020-12-06 08:08

I´m trying to create a form. This form have a package.json with vue, axios and sweetalert.

  \"dependencies\": {
    \"axios\": \"^0.19.0\",
    \"vue\": \"^         


        
相关标签:
3条回答
  • 2020-12-06 08:36

    I removed defer from

    <script src="{{ asset('js/app.js') }}" defer></script>
    

    and it worked perfectly

    0 讨论(0)
  • 2020-12-06 08:43

    You're trying to use an import statement in a normal script tag, you can only do that with type="module" but I suspect you will run into many other issues if you continue down this path as many libraries are not built for use with ESM modules yet.

    You'll be better off generating a project with https://cli.vuejs.org/ which will create a good starting base and compile your code and put it in a /build folder for you to deploy to your web hosting.

    0 讨论(0)
  • 2020-12-06 08:50
    require('__path_to_vue.js__')
    

    If you intend to use it outside module

    0 讨论(0)
提交回复
热议问题