日常項目中需要實現(xiàn)的一個價格脫敏功能:通過點擊頁面二中的查看完整信息 點擊回退按鈕實現(xiàn)頁面一中的價格顯露出來
通過查詢了大量資料發(fā)現(xiàn) 大多數(shù)都是通過調(diào)用上一個接口的onload 或者onshow 實現(xiàn)視圖更新
經(jīng)測試后 發(fā)現(xiàn) 無法實現(xiàn) 只能更改數(shù)據(jù) 無法更新視圖
實現(xiàn)方法 通過調(diào)用上一個頁面的自定義方法 通過setData 實現(xiàn)視圖更新
preDataUpdate(arr) {
this.setData({
tableList: arr
})
},
頁面2通過調(diào)用上一個頁面的方法來實現(xiàn)上一個頁面的視圖更新文章來源:http://www.zghlxwxcb.cn/news/detail-642496.html
refreshPrePage() {
const pages = getCurrentPages()
const perpage = pages[pages.length - 2]
console.log(perpage, '上一個頁面的數(shù)據(jù)')
if (perpage.route === 'subPackages/pages/mapLookHouse/index') {
perpage.__data__.houseList.map(item => {
// 符合條件的數(shù)據(jù)
if (this.data.info.ID === item.ID) {
item.price1 = item.WIDGET_1646100728243
item.price2 = item.WIDGET_1627373790294
}
perpage.preDataUpdate(perpage.__data__.houseList)
})
} else if (perpage.route === 'subPackages/pages/houseList/index') {
perpage.__data__.tableList.map(item => {
// 符合條件的數(shù)據(jù)
if (this.data.info.ID === item.ID) {
item.price1 = item.WIDGET_1646100728243
item.price2 = item.WIDGET_1627373790294
}
perpage.preDataUpdate(perpage.__data__.tableList)
})
}
},
文章來源地址http://www.zghlxwxcb.cn/news/detail-642496.html
到了這里,關(guān)于微信小程序?qū)崿F(xiàn)當(dāng)前頁面更新上一個頁面的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!