关于uniapp中v-for循环使用slice(0, 4)导致click事件报错问题

hykeda2年前uniapp382

在使用uniapp开发时遇到只要循环数组的前四个值,使用了slice函数,在添加click事件后报错:_vm.e0 is not a function

image.png

<view   v-for="(item,index) in abc.slice(0, 4)" :key="index" @click="showXphoto1(index)">
</view>

解决办法为abc数组使用计算属性computed处理:

<view   v-for="(item,index) in shotAbc" :key="index" @click="showXphoto1(index)">
</view>
computed:{
    shotAbc(){
        return this.abc.slice(0,4);
    }
}


相关文章

uniapp微信小程序保存base64图片的方法

使用uni.getFileSystemManager().writeFile去下载base64图片<view class="share-btn" @click="s...

uniapp开发微信小程序中使用block标签,在开发环境显示正常,生产环境中显示错误问题

在使用uniapp开发微信小程序时,使用了block标签进行了逻辑判断:<block v-show="list.type === 2">...

uni-app错误总结

H5页面中报错信息:[Vue warn]: Duplicate keys detected: 'pages/index/index'. This may cause an update...

uni-app注意点

uni-app注意点

vue只会将已经在data中声明的属性变为响应,没有声明的是不响应的,特别是数组和对象千万要注意export default({    data(){    &...

HBuilderX打开微信开发工具失败解决方案

先停止运行到微信开发工具, 然后在微信开发者工具设置-安全里面那个服务端口, 关闭再打开。重新运行就可以了 !...

微信小程序 getUserProfile直接进入fail函数,getUserProfile调用失败:fail can only be invoked by user TAP gesture.

问题描述小程序更改了调用用户信息的接口调用getUserProfile直接进入失败返回的错误信息如下getUserProfile:fail can only be invoked by user TA...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。