Method: 1. Embed JavaScript code in the script tag of the html page; 2. Write the js code in a ".js" file, and then introduce the external js file through the src attribute of the script tag, syntax ""
The operating environment of this tutorial: windows7 system, javascript1.8.5&&HTML5 version , Dell G3 computer.
1. Embed JavaScript code in the script tag of the html page
Example:
<body> <script> var a=1; alert(a); </script> </body>
2. Through the src attribute of the script tag Introducing external js files
<body> <!-- 引入本地文件 --> <script src="./script.js"></script> <!-- 引入外部域的文件 --> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> </body>
In this way, the server will send the JavaScript file to the browser with the MIME type application/x-javascript.
Note:
Although the