一、复制到剪贴板
const copyToClipboard = (text) =>
navigator.clipboard?.writeText && navigator.clipboard.writeText(text)
二、数组去重
const getUnique = (arr) => [...new Set(arr)]
三、滚动到顶部或底部
// 会滚动元素的父容器,使被调用scrollIntoView()的元素对用户可见
// 有兼容性问题
const scrollTo = (element, direction) =>
element.scrollIntoView({ behavior: "smooth", block: direction})
scrollTo(dom, 'start') // 滚动到dom所在位置顶部
scrollTo(dom, 'end') // 滚动到dom所在位置底部