Article directory
1. Introduction to the article
I am mainly engaged in java
back-end development, but I am also very interested in the front-end, and I am determined to become a full-stack engineer.
Currently learned web
the Three Musketeers:
-
Hypertext Markup Language
HTML(HyperTest Markup Language)
-
Cascading Style Sheets
CSS(Cascading Style Shets)
-
JavaScript
Back-end development spring
, mybatis
and other frameworks, I guess the front-end must also have a framework.
Sure enough, I searched the Internet, and the front end has vue
, react
, angularJs
and so on.
According to the personal plan, learn vue
the framework first.
If a worker wants to do a good job, he must first sharpen his tools. To learn vue
the framework well, start by downloading and installing it.
Next, I will 3
download and install using two methods vue.js
.
2. Environment construction
But vue.js
before installing, you need to install node.js
.
How to install node.js
, you can refer to the blog post: The latest tutorial on downloading and installing Node.js on the entire network in 2023
3. Install vue.js
I use the following 3
method to install vue.js
, but I recommend npm install
the way to install vue.js
.
3.1 Method 1: Download the vue.js source code from the official website
We click on the link on the right to go to vue.js
the official website, vue.js
the official website link address: https://cn.vuejs.org
- After entering the official website, select the document
vue 2 文档
, as shown in the figure below:
Or click this link to jump directly to Vue 2
the home page: https://v2.cn.vuejs.org
- After entering
Vue 2
the home page, click起步
the button, as shown in the figure below:
- On
vue 2
the page, slide the mouse down until you see<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
, as shown in the following figure:
- Open a new browser window, and copy the
src
filejs
(for examplehttps://cdn.jsdelivr.net/npm/vue@2/dist/vue.js
) in to the address bar of the window, as shown in the following figure:
- Use
Ctrl + A
andCtrl + C
, after copyingvue.js
the script code in the above picture. Create a new one in your projectjs文件
, copy the script code into this file, as shown in the following figure:
- Create a new
vueHtml
page and import the newly createdvue.js
file, as shown in the following figure:
Run vueHtml
the page, as shown in the figure below:
vueHtml
The source code for is as follows:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>测试vue.js脚本</title>
</head>
<body>
<div id="vm">
<p>Hello, {
{name}}!</p>
<p>You are {
{age}} years old!</p>
</div>
</body>
<script src="vue.js"></script>
<script type="text/javascript">
new Vue({
el: '#vm',
data: {
name: 'super先生',
age: 18
}
});
</script>
</html>
At present, except for a small number of projects Vue 2
, many projects have been upgraded Vue 3
to the official website 在2023 年 12 月 31 日停止维护Vue 2
, as shown in the following figure:
In order to prevent the code that cannot be downloaded later Vue 2
, I uploaded it to my cloud disk, click the following link to access:
-
Password: xbf4wv
3.2 Method 2: Use npm install to create
Since it vue
has been upgraded to Vue 3
, the official recommended npm install
way to install it vue
.
So, next, I used npm install
to install vue
.
- I'm going to build the project into
D:\project\test
the folder. Enter in the address bar of this foldercmd
, it can be opened directlycmd命令框
, and the current directory is located, as shown in the following figure:
- In
cmd
the command box, enter the following command
npm init vue@latest
This command will be installed and executed create-vue
, it is Vue
the official project scaffolding tool, as shown in the following figure:
As you can see in the picture above, I wrote Project name
yes testApp
and the rest is .Package name
package.json
No
If you are not sure whether to enable a certain function, you can directly press the Enter key to select No
.
- After the project is created, follow the prompts in the above figure and execute the following commands in sequence:
cd testVue
npm install
npm run dev
- Open the browser and enter: http://localhost:5173/ in the address bar , as shown in the figure below:
This page appears, indicating that the project has been created successfully.
3.3 Method 3: Use bower to download
bower
It is a front-end package management tool that can help us track front-end packages and ensure that they are up to date (or a specific version you specify).
- Install
bower
bower
Need node
, npm
and git
environment, after configuring these environments, npm
install them by way bower
, as shown in the following command
npm install bower -g
I use Windows powershell
, if you haven't installed it, you can click this link to install it: Install Windows powershell
- view
bower
version
After the installation is successful, enter the following command to view bower
the version:
bower -v
- Install
vue
Enter the following command to install vue:
bower i vue -g
4. Summary
Judging from the above vue.js
installation, I still recommend npm install
the way you use, after all, this is also the official recommended installation method.
Of course, I hope that installing the latest vue.js
tutorial as above can help you.