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

小程序模板網

微信小程序頁面跳轉navigator與傳遞參數,循環列表添加點擊事件和樣式 ...

發布時間:2018-04-18 09:39 所屬欄目:小程序開發教程

作者:xiao孛,來自原文地址

 

一:頁面跳轉navigator與傳遞參數

頁面之間跳轉使用 navigator標簽,wx.navigateTo ,wx.redirectTo

1、URL就是跳轉的頁面路徑.上面代碼中就是navigator目錄下的navigator頁面,title是參數。 
navigator下redirect屬性是值在當前頁打開.如果不加redirect就是跳轉到新頁面.都可以攜帶參數。

如果需要傳多個參數, 用 & 鏈接即可

 

				
  1. <navigator url="../navigator/navigator?title=我是navigate" >跳轉到新頁面</navigator>
  2. <navigator url="../redirect/redirect?title=我是redirect" open-type="redirect">在當前頁打開</navigator>

或者

 

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

2、在跳轉的js代碼可以獲取到title參數

 

				
  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

 

二:循環列表添加點擊事件和樣式

如果列表中項目的位置會動態改變或者有新的項目添加到列表中,并且希望列表中的項目保持自己的特征和狀態(如 <input/> 中的輸入內容,<switch/> 的選中狀態),需要使用 wx:key 來指定列表中項目的唯一的標識符。

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

  • 字符串,代表在 for 循環的 array 中 item 的某個 property,該 property 的值需要是列表中唯一的字符串或數字,且不能動態改變。
  • 保留關鍵字 *this 代表在 for 循環中的 item 本身,這種表示需要 item 本身是一個唯一的字符串或者數字,如: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里設一個變量,比如userCellId(JS文件在下面



易優小程序(企業版)+靈活api+前后代碼開源 碼云倉庫:starfork
本文地址:http://www.xiuhaier.com/wxmini/doc/course/23610.html 復制鏈接 如需定制請聯系易優客服咨詢:800182392 點擊咨詢
QQ在線咨詢
AI智能客服 ×