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

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

Description

@GeniusFunny

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions