在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
路由
范例:
"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages { "path": "pages/index/index", "style": { "navigationBarTitleText": "首页" } }, { "path": "pages/courseCassify/index", "style": { "navigationBarTitleText": "分类" } }, { "path": "pages/learnRecord/index", "style": { "navigationBarTitleText": "学习" } }, { "path": "pages/my/index", "style": { "navigationBarTitleText": "我的" } } ],
路由跳转
<template> <view> <view class="page-body"> <view class="btn-area"> <navigator url="navigate/navigate?title=navigate" hover-class="navigator-hover"> <button type="default">跳转到新页面</button> </navigator> <navigator url="redirect/redirect?title=redirect" open-type="redirect" hover-class="other-navigator-hover"> <button type="default">在当前页打开</button> </navigator> <navigator url="/pages/tabBar/extUI/extUI" open-type="switchTab" hover-class="other-navigator-hover"> <button type="default">跳转tab页面</button> </navigator> </view> </view> </view> </template> // navigate.vue页面接受参数 export default { onLoad: function (option) { //option为object类型,会序列化上个页面传递的参数 console.log(option.id); //打印出上个页面传递的参数。 console.log(option.name); //打印出上个页面传递的参数。 } }
url有长度限制,太长的字符串会传递失败,可使用窗体通信、全局变量,或 <navigator :url="'/pages/navigate/navigate?item='+ encodeURIComponent(JSON.stringify(item))"></navigator> // navigate.vue页面接受参数 onLoad: function (option) { const item = JSON.parse(decodeURIComponent(option.item)); } 注意
|
请发表评论