Vue Installation Preparations

0, install node, downloaded from the official website # vue-cli installation configuration process Node.js installed by default npm (package management tool).
. 1, the install NPM = -g CNPM --registry HTTPS: //registry.npm.taobao.org
2, the overall installation: npm install vue-cli -g (Global unloading: npm uninstall vue-cli -g) # must be installed globally vue-cli, otherwise it will not vue command
3, to see if the installation was successful: the Node -v
4, to see if the installation was successful: -V vue
front --- If you have already installed, and no need to install ---
5, the command-line operation : vue WebPACK YourProject the init
. 6, CD YourProject into our project directory vue
7, npm install dependencies installed our project, the install network is not good choice CNPM
. 8, enter the command line in the project directory UI -S-Element I NPM
. 9 mounted axios file --save axios install npm
10, run our program # dist directory generated under npm run dev development model is packed project directory after building

11, cnpm install eslint -g vuejs project development environment to build (ESlint installation)
12, npm install vue-Resource --save installed emergence of this issue in the learning process of vue, the description VueResource module is not installed.


vue has defined four kinds of variables
1data
variable data defined is that we need to maintain, will be changed several times or use the
2computed
variable computed in the calculation of the defined attributes are automatically calculated
to be noted that the computed variables can not be defined in the data, the conflict, said simply, data variables in our own control changes the definition of what would change or be assigned in different methods, such as shopping cart list data, will change in the additions and deletions to the process, we need to own to maintain this variable, do the processing corresponding to the additions and deletions to the time, however, the number of shopping cart variable but can be calculated from the shopping cart data, this time you can take advantage of computed properties help us to automatically calculate maintenance cart Qty this property value, do not need at the time of the additions and deletions to maintain themselves again manually modify the variable value of
3 created
in the life cycle, created before dom rendering is executed first, this variable is not usually defined inside change.
There are some common scenarios:
When you call sub-components, sub-assemblies we need to pass some parameters personalized, these parameters are defined just once, usually do not change, then you can re-created in the definition because it is executed before rendering component creation the
4 methods
there are three methods in the case of some of the functions in
the variables one is only within the function will be used, we only need to let the definition of like
one is in multiple functions is used we can with this.xxx to define, just like in the definition of data in almost
there is a defining constants defined with the const us directly out of export default just fine

Watch on the use of
the difference between the computed and watch
1 can monitor real-time calculation
2watch can monitor the data in the variable, computed data can not be calculated in the variable
3watch usage scenario
variables change in 1data too often, treatment can be used to monitor changes in the way
2 using the watch to control the order of execution, such as we need to do some processing is required before a value passed in can do, then you can monitor the value upon receiving this value, or the value changes, we began to deal with

Guess you like

Origin www.cnblogs.com/zjgtlkj/p/11360851.html