Skip to main content

2 posts tagged with "pit"

View All Tags

Arrow Function

· One min read
Lex
Front End Engineer @ Baoxiaohe

SO,今天又踩坑了,箭头函数没写返回值,返回包含undefined的数组。谁让箭头函数可以自动return呢👼

getBleedLine(item: Array<any>, faceData: Array<any> = this.getFaceData()) {  let res = Array<any>();  let emptyArr = Array<any>();
  for (let i = 0; i < faceData.length; i++) {    if (faceData[i].name === item[0]) {      for (let k = 1; k < item.length - 1; k++) {        emptyArr.push(faceData[i].dlist()[item[k]]);      }      res = emptyArr.map(ele => {        ele.x += item[item.length - 1].x ? item[item.length - 1].x : 0;        ele.y += item[item.length - 1].y ? item[item.length - 1].y : 0;        // warn: undefined + number = NaN        ele.cx = item[item.length - 1].x ?ele.cx+ item[item.length - 1].x : ele.cx;        ele.cy = item[item.length - 1].y ?ele.cy+ item[item.length - 1].y : ele.cy;
        return ele;      });      // console.log(res);    }  }
  return res;}

Translate

· One min read
Lex
Front End Engineer @ Baoxiaohe

水平垂直居中

  position fixed  top 50%  left 50%  transform translateX(-50%)  transform translateY(-50%)

Question is this is not useful.I find some blog ,but no get the answer.

translateX 和 translateY 单独拎出来是生效的,但是一起使用却有问题。这是为什么,Oh my god。谁来拯救我。

🆗,i make it with

position fixedtop 50%left 50%transform translate(-50%,-50%)

So,u should to read MDN more( •̀ ω •́ )y