瞄点平滑跳转
根据id,获取目标元素,通过 scrollIntoView 添加平滑效果
function anchor (el) {const element = document.getElementById(el.id)element.scrollIntoView({ behavior: 'smooth' })}
复制文本
https://zhuanlan.zhihu.com/p/53382478
https://www.jb51.net/article/201421.htm
https://blog.csdn.net/zhenghhgz/article/details/106273496
input | textarea
function copy (text) {const ipt = document.createElement('input');document.body.appendChild(ipt);ipt.setAttribute('value', text);ipt.select()console.log(ipt);try {// 'document.execCommand' is deprecateddocument.execCommand('copy');} catch (error) {console.log(error);} finally {document.body.removeChild(ipt)}}
selectAllChildren
页面居底
https://www.jianshu.com/p/c464576a43e4
handle() {console.log('到了底部')window.removeEventListener('scroll', this.handleScroll)},handleScroll() {const ele = document.documentElementconst body = document.body// 距离顶部距离const scrollTop = ele.scrollTop || body.scrollTop// 可视区高度const windowHeight = ele.clientHeight || body.clientHeight// 滚动条总高度const scrollHeight = ele.scrollHeight || body.scrollHeightif (scrollTop + windowHeight == scrollHeight) {// window.removeEventListener('scroll', handleScroll) // ?直接写handle()console.log('到了底部')}},window.addEventListener('scroll', handleScroll)
input number 上下箭头
input::-webkit-outer-spin-button,input::-webkit-inner-spin-button {-webkit-appearance: none;}input[type="number"] {-moz-appearance: textfield;}
