向上一个页面传递值
backConfirm() {
var pages = getCurrentPages()
// if (pages.length > 2) {
var currPage = pages[pages.length - 1] //当前页面
var prevPage = pages[pages.length - 2] //上一个页面
// #ifdef H5
prevPage.$vm.unittitle = val //h5写法
// #endif
prevPage.setData({
theUnittitle: {id:1}
})
uni.navigateBack()
}
获取下个页面传递过来的值
//兼容小程序,获取选中的值
//#ifdef MP-WEIXIN||MP-QQ
let pages = getCurrentPages();
let currPage = pages[pages.length - 1];
this.unittitle = currPage.data.theUnittitle;
if (currPage.data.theUnittitle) {
this.$set(this.model, 'work', currPage.data.theUnittitle.unitname)
this.$set(this.model, 'unitid', currPage.data.theUnittitle.unitid)
this.$set(this.model, 'topOrganizId', currPage.data.theUnittitle.topOrganizId)
this.$set(this.model, 'topOrganizName', currPage.data.theUnittitle.topOrganizName)
}
// #endif
分享
<u-cell icon="share" title="分享豫直先锋" openType="share" arrow-direction="right" @click="clickHandler"
:border="false"></u-cell>
//分享
uni.$u.mpShare.title = '豫直先锋'
uni.$u.mpShare.path = 'pages/index/index'
uni.$u.mpShare.imageUrl = '这个分享图片和分享标题做成后台可以替换的'
// #endif