使用 location.href= /url来跳转,简单方便,但是刷新了页面;
使用 history.pushState( /url ),无刷新页面,静态跳转;
引进 router,然后使用 router.push( /url )来跳转,使用了 diff算法,实现了按需加载,减少了 dom的消耗。其实使用 router跳转和使用 history.pushState()没什么差别的,因为 vue-router就是用了 history.pushState(),尤其是在 history模式下。
使用 location.href= /url来跳转,简单方便,但是刷新了页面;
使用 history.pushState( /url ),无刷新页面,静态跳转;
引进 router,然后使用 router.push( /url )来跳转,使用了 diff算法,实现了按需加载,减少了 dom的消耗。其实使用 router跳转和使用 history.pushState()没什么差别的,因为 vue-router就是用了 history.pushState(),尤其是在 history模式下。