1. table不能设置没有规律的某几行直接的间隔,只能设置每一行都有或每一行都没有 此时我们可以在想要间隔的地方设置一个空的tr标签
<tr></tr>
复制代码
  1. css3的animate可以设置动画暂停和继续

鼠标按住开始动画 松开停止动画

html,
body {
    width: 100%;
    height: 100%;
    cursor: pointer;
}
body:active div {
    animation-play-state: running;
}

div {
    margin: 50px auto;
    width: 100px;
    height: 100px;
    background: #000;
    animation: move 1s linear infinite alternate;
    animation-fill-mode: forwards ;
    animation-play-state: paused;
}

@keyframes move {
    0% {
        transform:translate(0, 0) rotate(0deg);
    }
    100% {
        transform: translate(500px, 0) rotate(360deg);
    }
}
复制代码
  1. 经常会遇到重复调用事件绑定多次的情况,解决办法:

jquery:

$("#foo").one("click", function() {
    console.log("Event fired once!!!");
});
复制代码

js:

select.once('click', buttonElement, function () {
    console.log('executed only once.');
});
复制代码

或者

buttonEl.addEventListener('click', function (e) {
    console.log('W3C标准事件');
},{once: true});
复制代码

vue:

<button v-on:click.once="doThis"></button>
复制代码
  1. 处理浮点数相加精度丢失问题

juejin.im/post/5ccfa5…

转载于:https://juejin.im/post/5cbe7fc65188250a7a67acff

Logo

汇聚全球AI编程工具,助力开发者即刻编程。

更多推荐