Vue-cli 3.0 index.html introduces dependent files, and other routing refreshes report errors

index.html introduces:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <link rel="icon" href="./favicon.ico">
    <title>SUPER_MAN</title>
  </head>
  <body>
    <div id="app"></div>
    <!-- built files will be auto injected -->
      <script type="text/javascript" src="./static/js/qunee-min.js"></script>
  </body>
</html>

after reboot, there is no problem when loading from the home page. But when it comes to other routes, refresh the browser. How to solve the problem that
Uncaught SyntaxError: Unexpected token <
appears?

Feb.12,2022

vue-cli3 changes the path of index.html. In version 2, it is under the root path. Now you need to put the static resource folder static under public, and then import the js file in this way. You wouldn't have made a mistake. I have no more questions here. You try.


just restart the project. Dizzy!


introduce jquery, in main.js and mount the $symbol on the Vue prototype

import $ from 'jquery'

Vue.prototype.$ = $;

use jquery methods in components

this.$('body').css('background-color','red');

https://webpack.docschina.org.


has the same problem been solved

?
Menu