组件生命周期show中的this没有指向?

小程序 文章 2021-12-21 12:00 333 0 全屏看文

AI助手支持GPT4.0

组件生命周期show中的this没有指向?The this in the component life cycle show does not point to?

组件生命周期show中的this没有指向?

官方文档地址https://developers.weixin.qq.com/miniprogram/dev/framework/custom-component/lifetimes.html

官方文档地址https://developers.weixin.qq.com/miniprogram/dev/framework/custom-component/lifetimes.html

回答:

brave:

你应该得这样调用

pageLifetimes: {    show() {      console.log(this)    }}pageLifetimes: {    show: function() {      console.log(this)    }}
春乏秋困夏盹冬眠:ok了
Lv: Max Human:
// 我们一直这样写的。pageLifetimes: {    show() {      console.log(this)    }},methods: {  initData: function () { // 很多人喜欢这样写      },  initData() {} // 而我们都简写。}
春乏秋困夏盹冬眠:

大哥大姐们帮忙看看啊

-EOF-

AI助手支持GPT4.0