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

在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']

要回复问题请先登录注册

  • 标题 / 粗斜体
  • 代码片段
  • 超链接 / 图片 / 视频
  • 列表 / 引用

文章内容较多时,可以用标题分段 :

## 大标题 
### 小标题

斜体 / 粗体 :

**粗体** 
*斜体*
***粗斜体***

代码片段 :

``` javascript
代码片段
```

超链接 :

[链接文字](链接地址) 例: [百度](http://www.baidu.com)

图片 :

![图片说明](图片地址) 例: ![百度logo](http://www.baidu.com/img/bdlogo.gif)

视频 :

!![视频说明](视频地址) 例: !![优酷视频](http://youku.com)

有序列表 :

1. 123
2. 123
3. 123

无序列表 :

- 123
- 123
- 123

引用 : ( 双回车后结束引用 )

> 引用内容
引用内容
引用内容