网友真实露脸自拍10p,成人国产精品秘?久久久按摩,国产精品久久久久久无码不卡,成人免费区一区二区三区

小程序模板網(wǎng)

微信小程序頁(yè)面跳轉(zhuǎn)navigator與傳遞參數(shù),循環(huán)列表添加點(diǎn)擊事件和樣式 ...

發(fā)布時(shí)間:2018-04-18 09:39 所屬欄目:小程序開發(fā)教程

作者:xiao孛,來(lái)自原文地址

 

一:頁(yè)面跳轉(zhuǎn)navigator與傳遞參數(shù)

頁(yè)面之間跳轉(zhuǎn)使用 navigator標(biāo)簽,wx.navigateTo ,wx.redirectTo

1、URL就是跳轉(zhuǎn)的頁(yè)面路徑.上面代碼中就是navigator目錄下的navigator頁(yè)面,title是參數(shù)。 
navigator下redirect屬性是值在當(dāng)前頁(yè)打開.如果不加redirect就是跳轉(zhuǎn)到新頁(yè)面.都可以攜帶參數(shù)。

如果需要傳多個(gè)參數(shù), 用 & 鏈接即可

 

				
  1. <navigator url="../navigator/navigator?title=我是navigate" >跳轉(zhuǎn)到新頁(yè)面</navigator>
  2. <navigator url="../redirect/redirect?title=我是redirect" open-type="redirect">在當(dāng)前頁(yè)打開</navigator>

或者

 

				
  1. // 跳轉(zhuǎn)到新頁(yè)面
  2. wx.navigateTo({
  3. url: "../navigator/navigator?title=我是navigate"
  4. })
  5. // 在當(dāng)前頁(yè)打開
  6. wx.redirectTo({
  7.     url: ../redirect/redirect?title=我是redirect"
  8. })

2、在跳轉(zhuǎn)的js代碼可以獲取到title參數(shù)

 

				
  1. Page({
  2. data:{
  3. title: "",
  4. },
  5. onLoad: function(options) {
  6. this.setData({
  7. title: options.title
  8. })
  9. }
  10. })

文件引用:

https://mp.weixin.qq.com/debug/wxadoc/dev/component/navigator.html?t=1476197487811

http://www.jianshu.com/p/0135769db89c

 

二:循環(huán)列表添加點(diǎn)擊事件和樣式

如果列表中項(xiàng)目的位置會(huì)動(dòng)態(tài)改變或者有新的項(xiàng)目添加到列表中,并且希望列表中的項(xiàng)目保持自己的特征和狀態(tài)(如 <input/> 中的輸入內(nèi)容,<switch/> 的選中狀態(tài)),需要使用 wx:key 來(lái)指定列表中項(xiàng)目的唯一的標(biāo)識(shí)符。

wx:key 的值以兩種形式提供

  • 字符串,代表在 for 循環(huán)的 array 中 item 的某個(gè) property,該 property 的值需要是列表中唯一的字符串或數(shù)字,且不能動(dòng)態(tài)改變。
  • 保留關(guān)鍵字 *this 代表在 for 循環(huán)中的 item 本身,這種表示需要 item 本身是一個(gè)唯一的字符串或者數(shù)字,如:numberArray: [1, 2, 3, 4]  wxml文件:
 

				
  1. <view class="userList" wx:for="{{items}}" wx:key="{{item.userId}} wx:for-index="idx"">
  2. <view class="{{userCellId==idx?'userCellActive':'userCell'}}" data-idx="{{idx}}" bindtap="userListAction">{{item.name}}</view>
  3. </view>

1、page.data里設(shè)一個(gè)變量,比如userCellId(JS文件在下面



易優(yōu)小程序(企業(yè)版)+靈活api+前后代碼開源 碼云倉(cāng)庫(kù):starfork
本文地址:http://www.xiuhaier.com/wxmini/doc/course/23610.html 復(fù)制鏈接 如需定制請(qǐng)聯(lián)系易優(yōu)客服咨詢:800182392 點(diǎn)擊咨詢
QQ在線咨詢
AI智能客服 ×