首页 > 其他 > 详细

bug问题-基础技巧

时间:2019-11-01 14:02:31      阅读:76      评论:0      收藏:0      [点我收藏+]

1.数据问题

b并不是a的克隆,而是指向同一份数据的另一个指针
let a = [1,2,3,4,5] let b = a b[0] = 6 console.log(a) // [6, 2, 3, 4, 5]
Object.assign({},a)用于将一个或多个源对象的所有可枚举属性,复制到目标对象,深度复制 let c = Object.assign([],a) c[0] = 6 console.log(c) // [6, 2, 3, 4, 5] console.log(a) // [1, 2, 3, 4, 5]
  利用es6的扩展运算符
  let arr = [...a]
  arr[0] = 0
  console.log(a)  //[1, 2, 3, 4, 5]
  console.log(arr) // [0, 2, 3, 4, 5]
 

 

2.双边距BUG(ie)

  上下两个垂直排列的元素

  .box1{margin-bottom: 10px;border: 1px dotted red;}
  .box2{margin-top: 20px;border: 1px dotted red;}

  技术分享图片

  解决方法:

    浮动:float:left

    外层元素:overflow:hidden

 

3.margin:0 auto(ie不生效) 

  首先页首必须设置文档类型:
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transition al.dtd">

  且在head内添加:
  <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/> 即可!

bug问题-基础技巧

原文:https://www.cnblogs.com/naturl/p/11763553.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!