Amitabha_597
Amitabha_597
  • 发布:2023-12-14 21:03
  • 更新:2023-12-14 21:16
  • 阅读:164

在nuiapp x中v-for 渲染的问题

分类:uni-app x
<template>  
    <view class="content">  
    <list-view id="list-view" style="flex: 1; background-color: #f5f5f5;">  
        <list-item v-for="item in list" :key="item.id" >  
        {{item.content}}  
        </list-item>  
    </list-view>  
    </view>  
</template>  

<script lang="uts">  
    export default {  
        data() {  
            return {  
                list:[  
                    {id:1,content:"测试"}  
                ]  
            }  
        },  
        onLoad() {  
        },  
        methods: {  
        }  

    }  

</script>

报错:
21:01:06.850 [plugin:uni:app-uts] 编译失败
21:01:06.850 ‌error: Unresolved reference: id‌
21:01:06.850 at pages/index/index.uvue:4:45
21:01:06.850 2 | <view class="content">
21:01:06.850 3 | <list-view id="list-view" style="flex: 1; background-color: #f5f5f5;">
21:01:06.850 4 | <list-item v-for="item in list" :key="item.id" >
21:01:06.850 | ^
21:01:06.850 5 | {{item.content}}
21:01:06.850 6 | </list-item>
21:01:06.850 ‌error: Unresolved reference: content‌
21:01:06.850 at pages/index/index.uvue:5:9
21:01:06.850 3 | <list-view id="list-view" style="flex: 1; background-color: #f5f5f5;">
21:01:06.850 4 | <list-item v-for="item in list" :key="item.id" >
21:01:06.850 5 | {{item.content}}
21:01:06.850 | ^
21:01:06.850 6 | </list-item>
21:01:06.850 7 | </list-view>

2023-12-14 21:03 负责人:无 分享
已邀请:
DCloud_UNI_FXY

DCloud_UNI_FXY

list:[ {id:1,content:"测试"} ] 未明确类型时,被推断为 UTSJSONObject[],访问属性需要使用索引访问,即item['id']

要回复问题请先登录注册