海mia婊婊想上岸

导航

一个问题产生的n个问题

1.怎么设置antd的<a-tree>的展开和关闭?

 

https://www.jianshu.com/p/d104f491b8c9里面看到一句

let {expandedKeys} = this.state

看不懂,去搜发现是js的最新标准es6的解构赋值规则


 

2.变量的解构赋值

阮一峰ES6:https://es6.ruanyifeng.com/?search=yield&x=5&y=9#docs/destructuring

本质上,这种写法属于“模式匹配”,只要等号两边的模式相同,左边的变量就会被赋予对应的值。下面是一些使用嵌套数组进行解构的例子。

数组例子

let [foo, [[bar], baz]] = [1, [[2], 3]];
foo // 1
bar // 2
baz // 3

let [ , , third] = ["foo", "bar", "baz"];
third // "baz"

let [x, , y] = [1, 2, 3];
x // 1
y // 3

let [head, ...tail] = [1, 2, 3, 4];
head // 1
tail // [2, 3, 4]

let [x, y, ...z] = ['a'];
x // "a"
y // undefined
z // []

对象例子

let { foo, bar } = { foo: 'aaa', bar: 'bbb' };
foo // "aaa"
bar // "bbb"

指定默认值

var {x, y = 5} = {x: 1};
x // 1
y // 5

在这一段又遇到看不懂的

function* fibs() {
  let a = 0;
  let b = 1;
  while (true) {
    yield a;
    [a, b] = [b, a + b];
  }
}

let [first, second, third, fourth, fifth, sixth] = fibs();
sixth // 5

关于*?

yield是干啥的?

Generator 函数是什么?


 

posted on 2021-09-24 15:49  海mia婊婊想上岸  阅读(38)  评论(0编辑  收藏  举报