<script>
export default {
name: "newsPage",
data() {
return {
formData: {
title: '',
author: '',
content: '',
},
isEditShow: false
};
},
mounted() {
this.isEditShow = false
uni.getStorage({
key: 'articleInfo',
success(res) {
console.log(this.formData)
console.log(res.data)
}
})
console.log("Mounted", this.formData)
},
destroyed() {
console.log("destroyed", this.formData)
}
}
</script>
console.log(this.formData) 显示的是 undefined
推测是 this指向的问题
修改代码
uni.getStorage({
key: 'articleInfo',
success: (res) => {
console.log(this)
this.isEditShow = false
this.formData = res.data
}
})