笔者参考博客https://blog.csdn.net/qq_35775675/article/details/82288571的做法后,的确成功了 。

下面是笔者的写法:

computed:注意不能直接在photoList后面加参数,没效果(应该是vue不支持),应该以JavaScript闭包的形式:

computed: {
            photoList() {
                return function(value){
                    var imgList = [];
                    for(var i=0;i<value.length;i++){
                        imgList.push({src: value[i]});
                    }
                    return imgList;
                }
            }

        }

template:

 <div>{{photoList(item.photo)}}</div>

最后的效果就是在div里面显示了计算属性photoList的返回值。

Logo

前往低代码交流专区

更多推荐