匿名用户x
匿名用户x
  • 发布:2021-03-12 15:42
  • 更新:2021-03-12 20:49
  • 阅读:1254

【报Bug】在 v-for 里使用对象 index打印为undefined

分类:uni-app

产品分类: uniapp/小程序/微信

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: win10

HBuilderX类型: 正式

HBuilderX版本号: 3.1.4

第三方开发者工具版本号: 1.03.2012120

基础库版本号: 2.16

项目创建方式: HBuilderX

操作步骤:
<template>  
        <view>  
            <view v-for="(value, name, index) in object" :key="index">  
                 {{ index }}. {{ name }}: {{ value }}  
            </view>  
        </view>  
    </template>  
    <script>  
        export default {  
            data() {  
                return {  
                    object: {  
                        title: 'How to do lists in Vue',  
                        author: 'Jane Doe',  
                        publishedAt: '2020-04-10'  
                    }  
                }  
            }  
        }  
    </script>

预期结果:

0.title: How to do lists in Vue,
1.author: Jane Doe,
2.publishedAt: 2020-04-10

实际结果:

undefined.title: How to do lists in Vue
undefined.author: Jane Doe,
undefined.publishedAt: 2020-04-10

bug描述:

在 v-for 里使用对象 index打印为undefined

2021-03-12 15:42 负责人:无 分享
已邀请:
DCloud_UNI_Anne

DCloud_UNI_Anne

在非H5平台 循环对象时不支持第三个参数,如 v-for="(value, name, index) in object" 中,index 参数是不支持的。

该问题目前已经被锁定, 无法添加新回复