子组件与父页面,data中都有一个imglist的属性。当父页面上的imglist有值的时候,子组件中imglist能够直接获取到这个值。而不用父组件给它传过去?
小程序组件能直接访问到父页面中的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?
回答:
组件中properties加个imglist属性,observers监听imglist
页面中 <xx imglist={{page.data.imglist}}></xx> setData imglist
是这个意思吧
需要传递