父页面向自定义组件中传递动态变量值?

小程序 文章 2020-09-03 11:01 500 0 全屏看文

AI助手支持GPT4.0

父页面向自定义组件中传递动态变量值?Does the parent page pass dynamic variable values ​​to custom components?

父页面向自定义组件中传递动态变量值?

现在有一个问题,就是有个页面当中使用了 标签,标签中使用了自定义的组件,现在想把每次滑动的页面ID ,传递到这个组件中去。后台的item数据,传递过去我在组件中都能接收到,就是这个滑动的页面ID 我传递不过去。写法我感觉是没错的。但不知道哪的原因获取不到。

下面的treeList 是后台的item数据可以接收到的,上面的那个就是页面ID ,接收不到,是组件不接受多个参数这样吗?

这个是父页面用组件的写法,我感觉没有什么错? 求各位大佬指点一下。实在不知道哪里出问题

Now there is a problem, that is, a page uses a tag and a custom component is used in the tag. Now I want to transfer the page ID of each slide to this component. The item data in the background can be received in the components after passing, but I can't pass the sliding page ID. I feel that the writing method is correct. But I don't know where to get it. The following treelist is the item data that can be received in the background. The one above is the page ID. if not, the component does not accept multiple parameters? This is the way to write the parent page with components. I don't think there is anything wrong with it? Please give me some advice. I don't know what went wrong

回答:

丶晓晓晓包:

传给子组件的数据不支持驼峰吧,tree-list,current-tab-num

仙ღ₅₂₀¹³¹⁴:


properties: { treeList: {  type: Object,  value: {} }}
安静:不是这种接收不到,LIST是可以的,是每次传过来的tab接收不到
仙ღ₅₂₀¹³¹⁴:你在currentTabNum的observer里 打印下 val 就知道了
安静:这个是每次都随着滑动有变化的,也就是有值的。但是要把这个值this.setData到data 里面是改变不了的。也就是说虽然在observer这个里面有val,但是我实际用不了
安静:
安静:就是页面的数字ID , 0和1这种

-EOF-

AI助手支持GPT4.0