摘要: 深度优先搜索和广度优先搜索是比较常见的算法,今天我们用js来实现以下 首先我们创建一下数据 const tree = { key: '第一层-1', children: [ { key: '第二层-1-1', children: [ { key: '第三层-1-1', children: [], } 阅读全文
posted @ 2020-08-10 21:45 毛小星 阅读(740) 评论(0) 推荐(0) 编辑
摘要: Array.prototype.my_filter = function(fn, context) { let resArr = [] const me = this const ctx = context ? context : this // 判断上下文 if (typeof fn !== 'f 阅读全文
posted @ 2020-08-05 22:34 毛小星 阅读(315) 评论(0) 推荐(0) 编辑
摘要: Array.prototype.my_map = function(fn, context) { let resArr = [] const me = this const ctx = context ? context : me // 定义上下文 if (typeof fn !== 'functi 阅读全文
posted @ 2020-08-05 22:20 毛小星 阅读(1482) 评论(0) 推荐(0) 编辑
摘要: vue2.0中去除了在v-html中使用filters方法,但是这是否意味着不可以这么使用了呢 html部分 <span v-html="$options.filters.contentFilters(item.data.description, this)" ></span> js部分 filte 阅读全文
posted @ 2020-08-03 09:58 毛小星 阅读(617) 评论(0) 推荐(0) 编辑
摘要: 周所周知,Vue在2.0版本中去除了$broadcast方法以及$dispatch方法,最近在学习饿了么的Element时重新实现了这两种方法,并以minix的方式引入。 废话不多说,上代码 function broadcast(componentName, eventName, params) { 阅读全文
posted @ 2020-08-03 09:37 毛小星 阅读(179) 评论(0) 推荐(0) 编辑
摘要: 你可以假设每种输入只会对应一个答案。但是,你不能重复利用这个数组中同样的元素。 示例: 给定 nums = [2, 7, 11, 15], target = 9 因为 nums[0] + nums[1] = 2 + 7 = 9 所以返回 [0, 1] 第一种方法 var twoSum = funct 阅读全文
posted @ 2020-05-31 22:15 毛小星 阅读(780) 评论(0) 推荐(0) 编辑
摘要: 记录一些数组去重的方法,如果有错误的地方,还望指正 1.利用es6中的Set()去重特性 const arr = [1,2,3,6,8,2,9,5,6,4,9] function uniq(arr) { return [...new Set(arr)] } const resultArr1 = un 阅读全文
posted @ 2020-05-31 22:05 毛小星 阅读(111) 评论(0) 推荐(0) 编辑