前置 rough-notation 用于在网页上创建注释并设置注释动画的小型 JavaScript 库。它还可以应用在一些常见前端框架中,比如 Vue、React、 Svelte、Angular 甚至 Web Component。我把它应用在我创建的博客园皮肤中,比如你可以看见头部导航条中的博客昵称有一个下划线。下面是它可以实现的基本效果,点击按钮试一试吧。 使用 npm install --save rough-notation 通过将元素传递到 annotation 来创建对象,以及通过配置来描述样式。拥有 annotation 对象后,可以调用 annotation.show() 显示。 import { annotate } from 'rough-notation'; const e = document.querySelector('#myElement'); const annotation = annotate(e, { type: 'underline' }); annotation.show(); 通过 Group 创建多个动画注释: import { annotate, annotationGroup } from 'rough-notation'; const a1 = annotate(document.querySelector('#e1'), {