小編給大家分享一下微信小程序中如何實現(xiàn)頁面跳轉(zhuǎn)傳參,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!

實現(xiàn)的功能是給列表增加點擊功能傳參到下一頁;

代碼如下:
<import src="../WXtemplate/headerTemplate.wxml"/>
<view>
<!--滾動圖-->
<view>
<swiper indicator-dots="{{indicatorDots}}" autoplay="{{autoPlay}}" interval="{{intervalTime}}" duration="{{Time}}">
<block wx:for="{{imageURl}}">
<swiper-item>
<image src="{{item}}" class="imagePX"></image>
</swiper-item>
</block>
</swiper>
</view>
<!--功能按鈕-->
<view class="section-bg">
<block wx:for="{{buttonNum}}">
<!--模版-->
<template is="buttonList" data="{{item}}"/>
<!--<view class="section-item">
<image class="section-img" src="{{item.image}}"></image>
<text class="section-text">{{item.text}}</text>
</view>-->
</block>
</view>
<!--資訊列表-->
<view>
<block wx:for="{{listNum}}">
<template is="newList" data="{{item,index}}"/>
</block>
</view>
</view>其中
<template is="buttonList" data="{{item}}"/>
為模版代碼如下
<template name="buttonList">
<view class="section-item">
<image class="section-img" src="{{item.image}}" bindtap="buttonClick"></image>
<text class="section-text">{{item.text}}</text>
</view>
</template>
<!--list-->
<template name="newList">
<view class="section-list" bindtap="listClick" id="{{index}}">
<view>
<image class="list-img" src="{{item.image}}"></image>
</view>
<view class="section-textt">
<view class="title"><text>{{item.title}}</text></view>
<view class="subTitle"><text>{{item.subTitle}}</text></view>
</view>
</view>
</template>這里只為下面的列表增加了點擊方法
點擊列表js代碼
listClick:function(event){
console.log(event);
var p = event.currentTarget.id
wx.navigateTo({url:'/pages/xiangqing/xiangqing?id=上一頁的參數(shù)'})
}其中
wx.navigateTo({url:'/pages/xiangqing/xiangqing?id=上一頁的參數(shù)'})
為跳轉(zhuǎn)方法,id為需要傳的參數(shù) 如果參數(shù)為動態(tài)參數(shù)代碼如下:
listClick:function(event){
console.log(event);
var p = event.currentTarget.id
wx.navigateTo({url:'/pages/xiangqing/xiangqing?id='+p})
}其中p為上面為每一行設置的id值
在下一頁取值代碼如下:
data:{
// text:"這是一個頁面"
title:''
},
onLoad:function(options){
// 頁面初始化 options為頁面跳轉(zhuǎn)所帶來的參數(shù)
this.setData({
title:options.id
})然后在頁面上顯示代碼如下:
<view>{{title}}</view>
最終實現(xiàn)效果:

以上是“微信小程序中如何實現(xiàn)頁面跳轉(zhuǎn)傳參”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學習更多知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!
文章名稱:微信小程序中如何實現(xiàn)頁面跳轉(zhuǎn)傳參-創(chuàng)新互聯(lián)
網(wǎng)站URL:http://chinadenli.net/article8/hhiop.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供App設計、關(guān)鍵詞優(yōu)化、軟件開發(fā)、虛擬主機、App開發(fā)、商城網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容