Skip to content
This repository has been archived by the owner on Jan 19, 2023. It is now read-only.
This repository has been archived by the owner on Jan 19, 2023. It is now read-only.

循环渲染自定义组件时,无法实现数据的双向绑定 #10

Open
GeniusFunny opened this issue Mar 3, 2018 · 1 comment
Open
Labels
bug Something isn't working

Comments

@GeniusFunny
Copy link
Member

wepy 1.X版本,使用repeat对自定义组件进行循环渲染时,无法将父组件的data双向绑定到子组件上,即repeat不支持props,computed,key值等等;而原生小程序的wx:for只支持原生组件。
目前的解决方案是: 使用repeat将父组件的data动态绑定(:sync.item)到子组件上,在子组件上添加一个事件发射器(this.$emit()),最后在父组件添加对应的events,从而达到数据的'伪'双向绑定。即修改数据的具体代码放在父组件上,而子组件拥有是否修改数据的控制权。
注:无法为子组件绑定key值,但可以为子组件绑定id,从而解决事件发射器的参数问题)

@GeniusFunny GeniusFunny added the bug Something isn't working label Mar 3, 2018
@ACERY1
Copy link
Member

ACERY1 commented Mar 13, 2018

不会再一次使用wepy了,never

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants