1.点语法 通过类似于 box.style.width, box.style.left 等,得到带有单位的属性值, 如:200px; 但是,点语法存在一个很致命的问题,跟在 style 后的属性不能由外传入 let h = 'height'; box.style.h = 300 + 'px'; // 无效 2.下标语法 利用 [] 访问属性 box.style[‘属性’]; let h = 'height'; box.style[h] = 300 + 'px'; // 可行