取色器 发表于 2021-10-12 更新于 2022-05-09 chrome97支持了取色器功能,支持用户点击从屏幕取色 支持检测123if(!window.EyeDropper){ console.error('不支持滴管api')} 使用实例12345678910let eyeif (window.EyeDropper) { eye = new EyeDropper() eye.open().then( (colorResult) =>{ console.log(colorResult.sRGBHex)} ).catch(e=>{ // 点击esc退出选取时触发 console.error('用户取消选择颜色') })} 在线运行 点击打开取色器 颜色展示(部分浏览器默认的颜色选择器可能无法观察实时的值)