帖子
帖子
用户
博客
课程
显示全部楼层
6
帖子
0
勋章
90
Y币

[开发工具] avm 组件数据绑定数组 子组件无法获取到数据

[复制链接]
发表于 2022-8-19 15:25:31
  向子组件通过动态绑定传递数据,绑定的数据为数组,子组件无法获取到数据。传递数据为字符串的时候,实时预览可以看到子组件渲染了数据,真机调试看不到渲染的数据。



例如:apicloud3新建stml页面的教培课程页 的模板案例新建后打开列表区域一片空白,数组数据无法传递到子组件中进行渲染。
6
帖子
0
勋章
90
Y币
父组件

  1. <view class="page">
  2.                 <safe-area></safe-area>
  3.                 <test-com :string='title' v-bind:list='data'></test-com>
  4.         </view>
复制代码


子组件
  1. <template>
  2.         <view class="page">
  3.                         <text>{{list}}</text>
  4.         </view>
  5. </template>
  6. <script>

  7. export default {
  8.         name: 'test-com',
  9.         props:{
  10.                 list:Array,
  11.                 string:String
  12.         },
  13.         apiready(){//like created
  14. console.log(JSON.stringify(this.props.list));
  15.         },
  16.         updated (){
  17. console.log(JSON.stringify(this.props.list));
  18.         },
  19.         data() {
  20.                 return{
  21.                         arr:this.props.list,
  22.                         title:this.props.string
  23.                 }
  24.         },
  25.         methods: {

  26.         }
  27. }
  28. </script>
  29. <style>
  30.         .page {
  31.                 height: 100%;
  32.         }
  33. </style>
复制代码


这样根本显示不了数据
我用vue 验证了一下 在vue中是可以的 但是在avm里边子组件获取不到props传递过来的数据
技术咨询-特特 · 2022-8-19 15:48参考下文档
https://docs.apicloud.com/apicloud3/#/components-guide/passing-by-value?index=5&subIndex=4
380
帖子
4
勋章
6
Y币
到模块store 下载一个组件,看其他人怎么写的,参考一下
您需要登录后才可以回帖 登录

本版积分规则