美文网首页
vue 中 去重方法 Element列表

vue 中 去重方法 Element列表

作者: 苏苡 | 来源:发表于2019-04-01 17:46 被阅读0次

//去重方法

            uniq(array){

                array.sort();

                var temp=[array[0]];

                for(var i = 1; i < array.length; i++){

                    if( array[i] !== temp[temp.length-1]){

                        temp.push(array[i]);

                    }

                }

                return temp;

            },

//   列表中使用

<el-table-column

                    prop="aaaaa"

                    label="目的地名称">

                    <template scope="scope">

                        {{uniq(scope.row.aaaaa.split(',')).join(',')}}

                    </template>

</el-table-column>

相关文章

网友评论

      本文标题:vue 中 去重方法 Element列表

      本文链接:https://www.haomeiwen.com/subject/yxcbbqtx.html