利涉大川
利涉大川
  • 发布:2019-04-23 19:35
  • 更新:2019-04-24 14:26
  • 阅读:1584

【报Bug】1.9.x版本,v-for 里的标签无法使用item和index

分类:uni-app

详细问题描述

(DCloud产品不会有明显的bug,所以你遇到的问题大都是在特定环境下才能重现的问题,请仔细描述你的环境和重现方式,否则DCloud很难排查解决你的问题)
1.9.x版本编译成微信小程序时 v-for="(item,index) in datalist" 里的标签使用fitler或者方法将item作为参数调用:fun(item);报错如下

Property or method "item" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property.

但是编译成头条小程序和h5时 可以正确运行****

[内容]

重现步骤

运行到微信小程序

[步骤]
Property or method "item" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property.
[结果]
正确调用item作为参数
[期望]

IDE运行环境说明

HBuilderX 1.9.3.20190422

mac 10.14.4

uni-app运行环境说明

微信小程序

1.02.1901230

[项目是cli创建的还是HBuilderX创建的?如果是cli创建的,请更新到最新版cli再试]

[编译模式是老模板模式还是新的自定义组件模式?]

[IDE问题请提供HBuilderX运行日志。菜单帮助-查看运行日志,点右键打开文件所在目录,将log文件压缩成zip包上传]

[App问题请提供可重现问题的代码片段,你补充的细一点,问题就解决的快一点]

[App安装包或H5地址]

[可重现代码片段]

联系方式

[QQ]271920265

2019-04-23 19:35 负责人:无 分享
已邀请:
Trust

Trust - 少说废话

请上传一个可以重现问题的测试项目/文件

HBuilderX 1.9.3 未能重现问题,测试代码:

<template>  
	<view>  
		<text v-for="item in list" :key="item">{{item | test}}</text>  
	</view>  
</template>  
  
<script>  
	export default {  
		data() {  
			return {  
				list: [1, 2, 3]  
			}  
		},  
		filters: {  
			test: function(value) {  
				return 'item:' + value;  
			}  
		},  
		methods: {  
  
		}  
	}  
</script>  
  
<style>  
  
</style>
  • 利涉大川 (作者)

    数据结构超过三层就有问题如下:

    <template>

    <view>

    <view>

    <view v-for="(item, index) in list" :key="item" @click="goIndex">{{item.item.id | test}}</view>

    </view>

    </view>

    </template>


    <script>

    export default {

    data() {

    return {

    list: []

    }

    },

    onShow: function() {

    this.list = [{

    item: {id:1}

    }, {

    item: {id:1}

    }, {

    item: {id:1}

    }];

    },

    filters: {

    test: function(value) {

    return 'item:' + value;

    }

    },

    methods: {

    goIndex: function() {

    wx.navigateTo({

    url: '/pages/index/index',

    })

    }

    }

    }

    </script>


    <style>


    </style>


    2019-04-24 16:21

  • Trust

    回复 利涉大川: 确认bug,目前的方案下这样使用会有问题,后续看有没有更好的办法支持下。目前建议在列表循环之前,进行一次数据的处理。


    2019-04-24 18:41

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