小程序不能向子组件传递数组吗
发布于 6 年前 作者 xia24 14903 次浏览 来自 问答

小程序不能向子组件传递数组吗

2 回复

<!-- 父组件 -->

<view>

<my-component s-name="[1,2,3]">

</my-component>

</view>

<!-- 子组件模板 -->

<view class=“wrapper”>

<view>这里是组件的内部节点</view>

</view>

<!-- 子组件js -->

Component({

/**

  * 组件的属性列表

  */

properties: {

sName: {

type: Array,

value: [],

observer(newVal, oldVal, changedPath) {

console.log(newVal)

}

}

},

/**

  * 组件的初始数据

  */

data: {

},

/**

  * 组件的方法列表

  */

methods: {

}

})

回到顶部