The Vue development environment has been built in the first step, now
Install and use VUE router for dynamic routing.
The first step is to install vue router:
Open cmd and enter the working directory, which is the folder where firstVue is located, and enter the command to install vue router: npm install vue-router
After the installation is complete, start using vue router:
①We create a new folder and name it view, and then create a new test.vue under the folder:
② Go to
router文件夹下
"
index.js文件
" Open and enter:
test.vue
components knock:
$route.params.testId
Is to get the parameters of the current route.
Then display after success:
Enter into the browser: http://localhost:8080/#/test/123 display:
Successfully install and use routing.
Next practice:
① Modify index.js routing file:
②Modify the test.vue file:
③Open cmd, enter npm run dev in the firstVue directory, and then enter into the browser: http://localhost:8080/#/test/123/name/xxx shows:
carry out.