微信小程式詳情頁面的資料渲染
阿新 • • 發佈:2021-01-05
雲函式程式碼:根據點選跳轉傳的id進行跳轉:
// 雲函式入口檔案
const cloud = require('wx-server-sdk')
cloud.init()
const db=cloud.database({
env: 'my-4gsns41r28791f4e',
})
// 雲函式入口函式
exports.main = async (event, context) => {
if(event.id){
return db.collection(event.table).where({_id:event.id}).get()
} else{
return db.collection(event.table).get()
}
主頁面的跳轉標籤:
詳情頁面的渲染:有標籤的資料用富文字
詳情頁面查詢雲函式庫:
onLoad: function (e) {
var es=e
var that=this;
wx.cloud.callFunction({
// 上傳的雲函式名稱
name: 'select',
// 傳給雲函式的引數
// data裡面的是表名
//id是連線裡面傳的id
data: {
table:"aboutinfo" ,
id:e.id
},
success: function(res) {
that.setData({
infos:res.result.data
})
},
fail: console.error
})
},