vue development WeChat Mini Programs learning process from the background of the data, the foreground can not render, print found a _ _ ob__: Observer, wanted data, but I can not get it, I would like to ask how to solve this problem.
Front end code
<template>
<div>
<div :key="index" v-for="(test, index) in tests">
{{test.title}}
{{test.ncName}}
</div>
</div>
</template>
<script>
import {get, showModal} from "@/util"
export default {
data(){
return {
userinfo: "",
tests: [],
}
},
methods:{
async getTests(){
const tests = await get("/weapp/getTests","")
this.tests = tests
console.log(tests)
// console.log(123,[...tests])
}
},
mounted(){
const userinfo = wx.getStorageSync("userinfo")
if(userinfo){
this.userinfo = userinfo
}
this.getTests()
}
}
</script>
backend
const {mysql} = require("../qcloud")
module.exports = async (ctx)=>{
const te = ctx.request.query
const tests = await mysql("questions")
.select("questions.*","cSessionInfo.user_info","department.deptName")
.join("cSessionInfo","questions.openId","cSessionInfo.open_id")
.join("department","questions.deptId","department.id")
.orderBy("questions.id","desc")
console.log(tests)
ctx.state.data = {
list: tests.map(v=>{
const info = JSON.parse(v.user_info)
return Object.assign({},v,{
user_info:{
ncName: info.nickName,
image: info.avatarUrl
}
})
})
}
// return ctx.state.data
}
Thank you first. I just got started, and my writing is very poor. It"s hard for everyone to help find out where the problem lies
.