Vue3中vue-router变化

实例创建方式

history选项代替了mode选项
  • history:createWebHistory()
  • hash:createWebHistory()
  • abstract:createMemoryHistory()
base选项移至createWebHistory等方法中,作为参数传入
createWebHistory('./xxx')
通配符 * 被移除

现在需要在path中用正则表达式来代替原来的*

`path:'*'`替换为 `path:'/:pathxx(.*)*'`
isReady()替代onReady

用于服务端渲染 onReady结果返回一个promise

现在keep-alive和transition 必须用在router-view内部
<!--before-->
<keep-alive>
	<router-view></router-view>
</keep-alive>

<!--now-->
<router-view>
	<keep-alive v-slot="{Component}">
    	<component :is="Component"></component>
    </keep-alive>
</router-view>
posted @ 2021-09-10 09:12  达不刘-  阅读(322)  评论(0编辑  收藏  举报