zoukankan      html  css  js  c++  java
  • 实践小结 (for in、style.width、overflow、~~)

    1、js 数组 for... in.. 中的 key 返回的是 string

    for(let key in store.userList){
         if(store.userList[key].loginName==loginName){
             this.slienceList.set(parseInt(key),isvoice);
         }
    }

    2、style.width接收的需要带px,如果是整数,将无法设置成功。

    const resize=()=>{
          camerasRef.current.style.width=`${styles.width}px`;
          camerasRef.current.style.height=`${styles.height}px`;
          camerasRef.current.style.left=`${styles.left}px`;
          camerasRef.current.style.top=`${styles.top}px`;
    }

     3、overflow:hidden  内层元素也设置圆角

    给父元素中设置overflow:hidden,子元素显示圆角。

     除此之外,overflow还有溢出隐藏、清除浮动、解决外边距塌陷等等作用,参考

     4、值类型和引用类型的区别

    function a() {
        var con = {};
        con.name = "ximing";
        con.age = "23";
        console.log("11", JSON.stringify(con));
        b(con);
        console.log("13", JSON.stringify(con));
    }
    
    function b(con) {
        con.address = "shanghai";
        console.log("12", JSON.stringify(con));
    }
    a();
    /*
    11 {"name":"ximing","age":"23"}
    12 {"name":"ximing","age":"23","address":"shanghai"}
    13 {"name":"ximing","age":"23","address":"shanghai"}
    */
    function c() {
        var age = 36;
        console.log("21", age);
        d(age);
        console.log("23", age);
    }
    
    function d(age) {
        age = 50;
        console.log("22", age);
    }
    c();
    /*
    21 36
    22 50
    23 36
    */

     5、~~的作用

    let minWidth = ~~(12.56);
    console.log(minWidth); //12

    ~是按位取反运算符 两个就是按位取反后再取反 这里相当于Math.floor() 不过效率高一点

  • 相关阅读:
    变量
    词频统计
    Python文件处理
    python面试题
    函数及组合数据类型
    位(bit)、字节(byte)、字符、编码之间的关系
    程序的控制结构
    Python:turtle库的使用及图形绘制
    Dynamics 365 CRM Connected Field Service 不能接收IoT Alert
    Dynamics 365 CRM 部署 Connected Field Service
  • 原文地址:https://www.cnblogs.com/liangtao999/p/14872612.html
Copyright © 2011-2022 走看看