首页 > 代码库 > vue路由
vue路由
1.同步路由
a.引入你想跳转的文件 import payment from ‘./app/payment‘
b.在路由里配置你的页面
const router = new VueRouter({
routes: [
{name:‘payment‘,path:‘/payment‘,component: payment} //path里的路径是指你浏览器显示的路径(例如http://localhost:9000/#/payment)
})
c.调用你的路由(我的实例代码是写在一个方法里的)
payMent(){
var obj={total:this.totalPrice}
router.push({
name:"payment",
params:obj //这必须传对象,不然界面会获取不到你想要传的值
})
}
2.异步路由
使用异步路由不需要引入文件,也就是同步路由中的a步骤不需要,
a.配置你要跳转的界面路由
const router = new VueRouter({
routes: [{name:‘payment‘,path:‘/payment‘,component:(resolve)=>{
require.ensure([‘./app/payment‘],()=>{
resolve(require(‘./app/payment‘))
})
}},
],
})
vue路由
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。