【发布时间】:2019-07-27 01:18:31
【问题描述】:
我正在使用模态显示 listView,我想将列表作为数组传递给模态。我这样称呼模态:
this.$showModal(Picker, { props: { list: [
{ name: "Item 1" },
{ name: "Item 2" },
{ name: "Item 3" }
]}});
模态加载正常,console.log时可以看到模态中的道具
created: function(){
console.log(this.list);
},
但是,我无法访问模板中的道具或循环它们。
<ListView for="item in listOfItems">
<v-template>
<Label :text="item.name" class="listItem" />
</v-template>
</ListView>
我也试过了:
<ListView :for="item in $props.list">
模态组件的完整代码如下:
<template>
<Page>
<ListView for="item in listOfItems">
<v-template>
<Label :text="item.name" class="listItem" />
</v-template>
</ListView>
</Page>
</template>
<script>
export default {
props: ["list"],
created: function(){
console.log(this.list);
},
data(){
return {
listOfItems: this.list
}
}
}
</script>
我做错了什么?
【问题讨论】:
标签: vue.js nativescript nativescript-vue