前端项目问题总结

185 阅读1分钟

1、async/await 里没到await直接return,导致后面所有接口返回都拿不到----后来查了不是这个原因,是因为list组件没有finished置false导致一直触发

image.png

2、在ts中怎样使页面异步加载失败,且不生效,改成esnext

image.png

3、svg改色 h5兼容性最好的,是滤镜,里面有个随意转换的工具,起始色没有改,颜色感觉也能变对,如果不是#000的起始色,不准的概率很大 www.zhangxinxu.com/wordpress/2… 用drop-dowm阴影,苹果12会有兼容性问题

4、# S获取音频的总时长,解决Audio元素duration为NaN || Infinity 问题 问题地址 最简单有用的

     audio.oncanplay = () => {
            const duration  = audio.duration
            console.log('audio.duration',audio.duration)
            if (duration === Infinity) {
              audio.currentTime = 1e101;
              audio.ontimeupdate = () => {
                audio.ontimeupdate = () => { return; };
                // 不重新设置currtTime,会直接触发audio的ended事件,因为之前将currentTime设置成了一个比音频时长还大的值。所以要将currentTime重置为初始状态。
                // 注: 这里有一个问题,直接设置为0 是不起作用的。需要重新设置一下audio.currentTime = 1e101;然后再设置为
                audio.currentTime = 1e101;
                audio.currentTime = 0;
              }
            }else {
              timeObj.totalTime = duration
            }
            emit('audioTime', audio.duration)
          }

5、背景色与背景图同存 background:url('@/assets/images/home/pcwl_3.webp') center bottom no-repeat, linear-gradient(360deg,#f8ffd1 1%, #e2ff3d); background-size: 100% 200px,100% 100%;

6、自己生成iconfont 文档

7、iconfont 多色 换色

8、h5手机键盘遮挡住输入框了文档