js数组去重

if (this.titles.includes(e.target.value)) {
                        //取消勾选
                        Array.prototype.indexOf = function (val) {
                            for (let i = 0; i < this.length; i++) {
                                if (this[i] == val) return i;
                            }
                            return -1;
                        };
                        Array.prototype.remove = function (val) {
                            let index = this.indexOf(val);
                            if (index > -1) {
                                this.splice(index, 1);
                            }
                        };
                        this.titles.remove(e.target.value)
                    } else {
                        this.titles.push(e.target.value);
                    }
posted @ 2020-12-06 23:03  星时代曹波涛  阅读(42)  评论(0编辑  收藏  举报