a标签跳转后关闭当前页面_微信小程序2020-day-2 导航项目(跳转三种形态)
生活随笔
收集整理的這篇文章主要介紹了
a标签跳转后关闭当前页面_微信小程序2020-day-2 导航项目(跳转三种形态)
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
day-2 導(dǎo)航項(xiàng)目(跳轉(zhuǎn)三種形態(tài))
轉(zhuǎn)發(fā)跳轉(zhuǎn):保留當(dāng)前頁(yè)面,跳轉(zhuǎn)新頁(yè)面,可返回
重定向跳轉(zhuǎn):關(guān)閉當(dāng)前頁(yè)面,跳轉(zhuǎn),不可返回,不能指定標(biāo)簽導(dǎo)航頁(yè)面
跳轉(zhuǎn)標(biāo)簽導(dǎo)航:跳轉(zhuǎn)到標(biāo)簽導(dǎo)航頁(yè)面,標(biāo)簽導(dǎo)航跟隨選中
app.json
{"pages":["pages/home/home","pages/navigator/navigator","pages/redirect/redirect"],"window":{"backgroundTextStyle":"light","navigationBarBackgroundColor": "#2ba008","navigationBarTitleText": "導(dǎo)航三種跳轉(zhuǎn)","navigationBarTextStyle":"white"},"tabBar": {"selectedColor": "#FFF","backgroundColor": "#2ba008","color": "#FFF","list": [{"pagePath": "pages/home/home","text": "首頁(yè)"},{"pagePath": "pages/redirect/redirect","text": "關(guān)閉頁(yè)面跳轉(zhuǎn)"}]},"style": "v2","sitemapLocation": "sitemap.json" }app.wxss
/**app.wxss**/.content {width: 100%;height: 100%;display: flex;flex-direction: column;align-items: center;box-sizing: border-box;font-family: Arial, Helvetica, sans-serif; }home.wxml
<!--pages/home/home.wxml--><view class="btn-area"><!-- 保留頁(yè)面跳轉(zhuǎn) --><navigator url="../navigator/navigator?title=Navigator" open-type="navigate" hover-class="navigator-hover">保留頁(yè)面跳轉(zhuǎn)</navigator><text>wx.navigateTo()</text><button type="primary" bindtap="navigateBtn" style="width:100%;">保留頁(yè)面跳轉(zhuǎn)</button><!-- 關(guān)閉頁(yè)面跳轉(zhuǎn) --><navigator url="../navigator/navigator?title=Redirect" open-type="redirect" hover-class="other-navigator-hover">關(guān)閉頁(yè)面跳轉(zhuǎn)</navigator><text>wx.redirectTo()</text><button type="primary" bindtap="redirectBtn" style="width:100%;">關(guān)閉頁(yè)面跳轉(zhuǎn)</button><!-- 關(guān)閉頁(yè)面跳轉(zhuǎn) --><navigator url="../redirect/redirect?title=Switch" open-type="switchTab" hover-class="other-navigator-hover">標(biāo)簽導(dǎo)航頁(yè)面跳轉(zhuǎn)</navigator><text>wx.switchTo()</text><button type="primary" bindtap="switchBtn" style="width:100%;">標(biāo)簽導(dǎo)航頁(yè)面跳轉(zhuǎn)</button></view>home.wxss
/* pages/home/home.wxss */.btn-area{display: flex;flex-direction: column;align-items: center;width: 100%; }navigator{width: 100%;height: 100rpx;background: honeydew;text-align: center;line-height: 100rpx; }text{width: 100%;height: 100rpx;background: cadetblue;text-align: center;line-height: 100rpx;color: white; }button{margin-bottom: 30rpx; }.navigator-hover{color: blue; }.other-navigator-hover{color: red; }homs.js
// pages/home/home.js Page({/*** 頁(yè)面的初始數(shù)據(jù)*/data: {},/*** 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面加載*/onLoad: function (options) {},navigateBtn:function(){wx.navigateTo({url: '../navigator/navigator?title=NavigatorTo',success:function(res){console.log(res);},fail:function() {},complete:function() {}});},redirectBtn:function(){wx.redirectTo({url: '../navigator/navigator?title=RedirectTo',success:function(res){console.log(res);},fail:function() {},complete:function() {}});},switchBtn:function(){wx.switchTab({url: '../redirect/redirect?title=SwitchTab',success:function(res){console.log(res);},fail:function() {},complete:function() {}});} })redirect.wxml
<!--pages/redirect/redirect.wxml--> <text>pages/redirect/redirect.wxml</text> <text>關(guān)閉當(dāng)前頁(yè)面,單機(jī)左上角的可以跳轉(zhuǎn)HOME</text>navigator.wxml
<!--pages/navigator/navigator.wxml--> <text>pages/navigator/navigator.wxml</text> <text>保留當(dāng)前頁(yè)面,單機(jī)左上角的可以返回</text> <button type="primary" bindtap="backBtn">返回上一頁(yè)</button>navigator.js
// pages/navigator/navigator.js Page({/*** 頁(yè)面的初始數(shù)據(jù)*/data: {},/*** 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面加載*/onLoad: function (options) {// options 獲取提交的數(shù)據(jù)var title = options.title;console.log(title);// 設(shè)置當(dāng)前頁(yè)面的導(dǎo)航標(biāo)題wx.setNavigationBarTitle({title: title,});// 設(shè)置導(dǎo)航的加載動(dòng)畫(huà)wx.showNavigationBarLoading();},backBtn:function(){// getCurrentPages() 獲取當(dāng)前頁(yè)面棧// 1 首頁(yè)wx.navigateBack({delta: 1,});} })項(xiàng)目截圖
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來(lái)咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的a标签跳转后关闭当前页面_微信小程序2020-day-2 导航项目(跳转三种形态)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: python gui tkinter_p
- 下一篇: lin通信ldf文件解析_手把手教你在C