When learning vue, I encountered many problems. Here are some summary and updates.
Today I will talk about a problem, which is the problem encountered when I was learning vue, when I upgraded from the previous version 1.0. A simple setting of default routes.
In the official vue document, there is no case or explanation for this, I don’t know if I haven’t discovered it. Anyway, this problem is a small pitfall encountered. Forgive a rookie and understand nothing.
During the process of reviewing the article, I found that some seniors summarized this knowledge.
The specific implementation is as follows:
import Vue from 'vue' import Router from 'vue-router' import goods from '../components/goods/goods' import ratings from '../components/ratings/ratings' import seller from '../components/seller/seller' (Router) export default new Router({ routes: [ {path: '/', redirect: 'goods'}, {path: '/goods', component: goods}, {path: '/ratings', component: ratings}, {path: '/seller', component: seller} ] })
In fact, if you want to say, the document also has this explanation, which is redirection. redirect relocates the path when entering and relocates to goods, and can open the goods page as soon as you come in. This is actually the same.
The above example of setting the default path of router-view in vue2 is all the content I share with you. I hope you can give you a reference and I hope you can support me more.