Description
The article for vue.js Setup.
Original post link:https://www.cnblogs.com/markjiang7m2/p/10783456.html
Source code:https://gitee.com/Sevenm2/Vue.Web/tree/master/Vue.Web
Development Environment Preparation
Node.js
If we want to develop Vue.js, we should install Node.js firstly.
Actually I have installed Node.js in my environment when I started my another repository TaxSystem, but without any note to mark down the action. I will write down the procedure here.
1.Install Node.js
Download Node.js install package from nodejs.org and install. You should select your version.![Vue Study [1]: Vue Setup Vue Study [1]: Vue Setup](http://code.bmoook.com/wp-content/uploads/2023/03/20230308192520-6408e120573a0.png)
Set environment variables![Vue Study [1]: Vue Setup Vue Study [1]: Vue Setup](http://code.bmoook.com/wp-content/uploads/2023/03/20230308192520-6408e120ce840.png)
And then you can input the command line to verify if Node.js is installed successfully.
node -v
npm -v
![Vue Study [1]: Vue Setup Vue Study [1]: Vue Setup](http://code.bmoook.com/wp-content/uploads/2023/03/20230308192521-6408e1215aab2.png)
2.Environment Configuration
The node cache files and global modules will be installed and saved into C:\Users\xxx\AppData\Roaming\npm by default. We have better to change the path as our system disk space is limited.
Create 2 folders node_global & node_cache![Vue Study [1]: Vue Setup Vue Study [1]: Vue Setup](http://code.bmoook.com/wp-content/uploads/2023/03/20230308192521-6408e121adf50.png)
Reset the configuration in CMD.
npm config set prefix "D:\Mark\nodejs\node_global"
npm config set cache "D:\Mark\nodejs\node_cache"
Add the environment variables![Vue Study [1]: Vue Setup Vue Study [1]: Vue Setup](http://code.bmoook.com/wp-content/uploads/2023/03/20230308192522-6408e12216527.png)
vue-cli
Install vue-cli as a global module.
npm install -g vue-cli
![Vue Study [1]: Vue Setup Vue Study [1]: Vue Setup](http://code.bmoook.com/wp-content/uploads/2023/03/20230308192522-6408e12296d1a.png)
Input a command line to verify if vue-cli is installed successfully.![Vue Study [1]: Vue Setup Vue Study [1]: Vue Setup](http://code.bmoook.com/wp-content/uploads/2023/03/20230308192523-6408e12307775.png)
Setup a vue project
Use Visual Studio Code to open the folder you want to create the project in.
Click Ctrl + ~ to open the Terminal.
Input the below command line to new a project based on webpack and select the setting as requested.
vue init webpack projectname
![Vue Study [1]: Vue Setup Vue Study [1]: Vue Setup](http://code.bmoook.com/wp-content/uploads/2023/03/20230308192523-6408e1235d2bd.png)
Config the PORT No.![Vue Study [1]: Vue Setup Vue Study [1]: Vue Setup](http://code.bmoook.com/wp-content/uploads/2023/03/20230308192523-6408e123c8d40.png)
Enter the project folder and run the project
cd Vue.Web
npm run dev
![Vue Study [1]: Vue Setup Vue Study [1]: Vue Setup](http://code.bmoook.com/wp-content/uploads/2023/03/20230308192524-6408e12450e65.png)
Then we can view the Website in browser.![Vue Study [1]: Vue Setup Vue Study [1]: Vue Setup](http://code.bmoook.com/wp-content/uploads/2023/03/20230308192524-6408e124af4a7.png)
We can also build the project
npm run build .
![Vue Study [1]: Vue Setup Vue Study [1]: Vue Setup](http://code.bmoook.com/wp-content/uploads/2023/03/20230308192525-6408e1252e62c.png)
![Vue Study [1]: Vue Setup Vue Study [1]: Vue Setup](http://code.bmoook.com/wp-content/uploads/2023/03/20230308192525-6408e12588a1f.png)
vetur
It is an extension Vue tooling for VS Code.
1.Install vetur
Click Ctrl + P, input ext install vetur, then install the extension.
2.Add the below in User settings
Click Ctrl + Shift + P, input Preferences: Open User Settings.
Add the below in User settings
"emmet.syntaxProfiles": {
"vue-html": "html",
"vue": "html"
}
Build Setup command line
# install dependencies
npm install
# serve with hot reload at localhost:8080
npm run dev
# build for production with minification
npm run build
# build for production and view the bundle analyzer report
npm run build --report
# run unit tests
npm run unit
# run e2e tests
npm run e2e
# run all tests
npm test