欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

微信小程序 頁面跳轉(zhuǎn)傳遞值幾種方法詳解

 更新時間:2017年01月12日 17:15:18   投稿:lqh  
這篇文章主要介紹了微信小程序 頁面跳轉(zhuǎn)傳遞值幾種方法詳解的相關資料,需要的朋友可以參考下

微信小程序 頁面跳轉(zhuǎn)傳遞值

微信小程序?qū)Ш接袃煞N形式:一種是在寫在js中進行跳轉(zhuǎn),另一種是寫在wxml頁面中進行跳轉(zhuǎn)。

1、js導航

 (1)、wx.navigateTo(OBJECT) :保留當前頁面,跳轉(zhuǎn)到應用內(nèi)的某個頁面,使用wx.navigateBack可以返回到原頁面。


wx.navigateTo({ 
 url: 'test?id=1' 
}) 

獲取傳遞的值:

//test.js 
Page({ 
 onLoad: function(option){ 
  console.log(option.id) 
 } 
}) 

 (2)、wx.redirectTo(OBJECT):關閉當前頁面,跳轉(zhuǎn)到應用內(nèi)的某個頁面。


wx.redirectTo({ 
 url: 'test?id=1' 
}) 

 (3)、wx.navigateBack(OBJECT):關閉當前頁面,返回上一頁面或多級頁面??赏ㄟ^ getCurrentPages()) 獲取當前的頁面棧,決定需要返回幾層。

2、wxml導航

navigator:頁面鏈接。


注:navigator-hover默認為{background-color: rgba(0, 0, 0, 0.1); opacity: 0.7;}, <navigator/>的子節(jié)點背景色應為透明色

示例代碼:

/** wxss **/ 
/** 修改默認的navigator點擊態(tài) **/ 
.navigator-hover { 
  color:blue; 
} 
/** 自定義其他點擊態(tài)樣式類 **/ 
.other-navigator-hover { 
  color:red; 
} 
<view class="btn-area"> 
 <navigator url="navigate?title=navigate" hover-class="navigator-hover">跳轉(zhuǎn)到新頁面</navigator> 
 <navigator url="redirect?title=redirect" redirect hover-class="other-navigator-hover">在當前頁打開</navigator> 
</view> 

獲取頁面?zhèn)鬟f的值:

// redirect.js navigator.js 
Page({ 
 onLoad: function(options) { 
  this.setData({ 
   title: options.title 
  }) 
 } 
}) 

感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!

相關文章

最新評論