小程序组件能直接访问到父页面中的data值?

小程序 文章 2022-04-21 23:20 715 0 全屏看文

AI助手支持GPT4.0

小程序组件能直接访问到父页面中的data值?Can the applet component directly access the data value in the parent page?

小程序组件能直接访问到父页面中的data值?

子组件与父页面,data中都有一个imglist的属性。当父页面上的imglist有值的时候,子组件中imglist能够直接获取到这个值。而不用父组件给它传过去?

There is an imglist attribute in the data of the child component and the parent page. When the imglist on the parent page has a value, the imglist in the child component can directly obtain this value. Without the parent component passing it?

回答:

陈宇明:

需要传递

y40,:

组件中properties加个imglist属性,observers监听imglist

页面中 <xx imglist={{page.data.imglist}}></xx> setData imglist

是这个意思吧

55:111

-EOF-

AI助手支持GPT4.0