页面的wx:for 如何引用 data内的其他变量?

小程序 文章 2020-08-11 18:01 685 0 全屏看文

AI助手支持GPT4.0

页面的wx:for 如何引用 data内的其他变量?How does the page's wx:for reference other variables in data?

页面的wx:for 如何引用 data内的其他变量?

js数据:

data:{

myArray:[1,2,3],

otherData:xxx

}

页面:

《view wx:for={{myArray}} ..... 》

{{otherData}} //作用域的问题,这里得不到数据 ,2年前我解决过一次,前面加个语法类似 {{parent.otherData}} 但具体忘记了。高人给偶老年痴呆一个语法呗? 补充:也可能我记忆错位了。解决过其他前端框架类似问题。而不是微信小程序的。

还能编辑吗?呃,问题有变化,是我在页面得不到Data内定义为Map集合的数据。。。。打扰了各位。。。

《/view》

JS data: data: {myArray: [1,2,3], otherData:xxx }Page: View Wx: for = {myArray}}}} / / scope problem, no data is available here. I solved it once two years ago, and added a syntax similar to it{{ parent.otherData }}But I forgot. Senior people give me a grammar for Alzheimer's disease? Add: Maybe my memory is misplaced. Solved similar problems in other front-end frameworks. Not wechat applet. Can you edit it? Er, the problem has changed. I can't get the data defined as the map set in the data on the page.... Excuse me... 《/view》

回答:

IT.野狐禅:

js: data{ otherData:new Map(...) } //初识化数据了

页面: {{otherData.get(0) }} 得不到

页面直接:{{otherData}} 能有显示 [object]

-EOF-

AI助手支持GPT4.0