当前位置:网站首页>Route jump in wechat applet
Route jump in wechat applet
2022-07-07 07:38:00 【richest_ qi】
List of articles
Antecedents feed
Common methods supporting route jump in wechat applet API Yes ,
wx.navigateTo()
, Keep the current page , Jump to a page in the application . however , You can't jump to tabbar page .wx.redirectTo()
, Close current page , Jump to a page in the app .wx.reLaunch()
, Close all pages , Open a page in the application .wx.switchTab()
, Jump to tabbar page , And shut down all the others tabbar page .
Applet project
The main files involved in the code are :
- app.json
- app.wxss
- pages/home/home.wxml
- pages/home/home.json
- pages/camera/camera.wxml
- pages/camera/camera.json
- pages/user/user.wxml
- pages/user/user.json
- pages/login/login.wxml
- pages/login/login.json
- pages/login/login.wxss
- pages/login/login.js
The main body
app.json
{
"pages": [
"pages/home/home",
"pages/camera/camera",
"pages/user/user",
"pages/login/login"
],
"window": {
"navigationBarBackgroundColor": "#0149af",
"navigationBarTitleText": " home page ",
"navigationBarTextStyle": "white"
},
"tabBar": {
"color": "#0149af",
"selectedColor": "#0149af",
"list": [{
"pagePath": "pages/home/home",
"text": " home page ",
"iconPath": "/static/images/tabIcons/homepage.png",
"selectedIconPath": "/static/images/tabIcons/homepage_fill.png"
},{
"pagePath": "pages/camera/camera",
"text": " Photo album ",
"iconPath": "/static/images/tabIcons/camera.png",
"selectedIconPath": "/static/images/tabIcons/camera_fill.png"
},{
"pagePath": "pages/user/user",
"text": " Personal center ",
"iconPath": "/static/images/tabIcons/people.png",
"selectedIconPath": "/static/images/tabIcons/people_fill.png"
}]
},
"style": "v2",
"sitemapLocation": "sitemap.json"
}
app.wxss
.container{
margin: 40rpx;
padding: 40rpx;
height: 600rpx;
background:#a3c8f8;
border-radius: 6rpx;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
font-size: 48rpx;
color: #fff;
}
home page (pages/home)
pages/home/home.wxml
<view class="container">
home page
</view>
Photo album (pages/camera)
pages/camera/camera.wxml
<view class="container">
Photo album
</view>
pages/camera/camera.json
{
"navigationBarTitleText": " Photo album "
}
Personal center (pages/user)
pages/user/user.wxml
<view class="userContainer">
<image src="/static/images/vistor.png"></image>
<view class="name"> tourists </view>
<view class="text" bindtap="handleTap"> Go to login ?</view>
</view>
pages/user/user.json
{
"navigationBarTitleText": " Personal center "
}
Sign in (pages/login)
pages/login/login.wxml
<view class="loginContainer">
<view class="title"> Sign in </view>
<view class="list">
<view class="item">
<input type="text" data-type="username" bindinput="handleInput" placeholder=" user name " />
</view>
<view class="item">
<input type="text" password data-type="password" bindinput="handleInput" placeholder=" password " />
</view>
</view>
<button size="mini" bindtap="login"> Sign in </button>
</view>
pages/login/login.json
{
"navigationBarTitleText": " Sign in "
}
pages/login/login.wxss
.loginContainer{
padding: 20rpx;
}
.loginContainer .title{
padding: 20rpx 0;
border-bottom: 1px solid #ddd;
font-weight: bold;
font-size: 32rpx;
}
.list{
margin: 40rpx auto 20rpx;
}
.item{
margin: 12rpx 0;
padding: 0 20rpx;
border: 1px solid #ddd;
border-radius: 6rpx;
}
.item input{
width: 100%;
height: 60rpx;
font-size: 28rpx;
}
button{
font-weight: normal;
font-size: 28rpx!important;
color: #fff;
background: #0149af;
}
pages/login/login.js
Page({
data:{
username:"",
password:""
},
handleInput(e){
const type = e.target.dataset.type;
this.setData({
[type]:e.detail.value
})
},
login(){
const {
username,password} = this.data;
if(!username){
wx.showToast({
title: ' Please enter your user name ',
icon:'error'
})
return;
}
if(!password){
wx.showToast({
title: ' Please enter your password ',
icon:'error'
})
return;
}
wx.showToast({
title: ' Login successful ',
success:() => {
setTimeout(() => {
wx.switchTab({
url: '/pages/user/user',
})
},300)
}
})
/** * Report errors :navigateTo:fail can not navigateTo a tabbar page */
// wx.navigateTo({
// url: '/pages/user/user',
// })
}
})
Related links
边栏推荐
- Wechat applet full stack development practice Chapter 3 Introduction and use of APIs commonly used in wechat applet development -- 3.10 tabbar component (I) how to open and use the default tabbar comp
- Tumor immunotherapy research prosci Lag3 antibody solution
- Initial experience of teambiion network disk (Alibaba cloud network disk)
- Leetcode-543. Diameter of Binary Tree
- The currently released SKU (sales specification) information contains words that are suspected to have nothing to do with baby
- 抽絲剝繭C語言(高階)指針的進階
- JSON introduction and JS parsing JSON
- 外包幹了三年,廢了...
- Apache AB stress test
- Differences between H5 architecture and native architecture
猜你喜欢
The currently released SKU (sales specification) information contains words that are suspected to have nothing to do with baby
Advanced practice of C language (high level) pointer
抽丝剥茧C语言(高阶)指针的进阶
外包幹了三年,廢了...
深度学习花书+机器学习西瓜书电子版我找到了
3、 High quality programming and performance tuning practical youth training camp notes
Outsourcing for three years, abandoned
抽丝剥茧C语言(高阶)数据的储存+练习
URP - shaders and materials - light shader lit
After 95, Alibaba P7 published the payroll: it's really fragrant to make up this
随机推荐
外包干了三年,废了...
Summary of customer value model (RFM) technology for data analysis
Talk about seven ways to realize asynchronous programming
Mobx knowledge point collection case (quick start)
按键精灵脚本学习-关于天猫抢红包
Invalid table alias or column reference`xxx`
PostgreSQL source code (60) transaction system summary
ASEMI整流桥RS210参数,RS210规格,RS210封装
About some details of final, I have something to say - learn about final CSDN creation clock out from the memory model
BGP experiment (1)
按键精灵采集学习-矿药采集及跑图
2、 Concurrent and test notes youth training camp notes
Flutter riverpod is comprehensively and deeply analyzed. Why is it officially recommended?
resource 创建包方式
Redis data migration
Detailed explanation of neo4j installation process
Role of virtual machine
Example of Pushlet using handle of Pushlet
Calculus key and difficult points record part integral + trigonometric function integral
Detailed explanation of transform origin attribute