- 箭头函数在构造函数中声明指向实例
const Person = function(name){
this.name = name
}
//this->new Person()
2.类字段实际上是在构造函数声明的
//作为类字段的箭头函数
class MyClass {
myArrowFunction = () => {
console.log(this);
};
}
//类字段语法是ES2022标准的一部分,它实际上是语法糖,上面的代码等价于:
class MyClass {
constructor() {
this.myArrowFunction = () => {
console.log(this);
};
}
}
3.flex:1,flex:auto的区别
| 简写属性 | 完整写法 | flex-grow | flex-shrink | flex-basis |
|---|---|---|---|---|
| flex:1 | flex: 1 1 0% | 1 | 1 | 0% |
| flex:auto | flex: 1 1 auto | 1 | 1 | auto |
0%,不预先分配宽度,直接根据剩余空间按比例分配宽度
auto,预先分配内容宽度,再根据剩余空间按比例分配。
auto 示例,不等分