1、鼠标横向滚动
this.$nextTick(() => {
scrollDom = document.getElementById('monitor-type-scroll')
scrollDom?.addEventListener('mousewheel', this.mouserScroll, false)
this.$once('hook:beforeDestroy', () => {
scrollDom.removeEventListener('mousewheel', this.mouserScroll)
})
})
mouserScroll(event){
let detail = event.wheelDelta || event.detail
let step = detail > 0 ? -1 * 100 : 1 * 100
scrollDom.scrollLeft += step
}
2、首字母大写,三种都可以
1、val.substring(0, 1).toUpperCase() + val.substring(1)
2、name.slice(0, 1).toUpperCase() + name.slice(1)
3、name.charAt(0).toUpperCase() + name.slice(1)
3、字符串HTML中的事件传对象,一般不用
onClick="viewInfo(${JSON.stringify(object).replace(/\"/g,"'")})"
4、密码验证
let reg2 = /^(?=[A-Z]+)(?=.*[A-Z])(?=.*[a-z])(?=.*[^a-zA-Z0-9]).{8,20}$/
export function validatPassword(rule, value, callback) {
if (!value) {
callback()
} else if (!reg2.test(value)) {
callback(new Error('密码必须大写字母开头,由8~20位大小字母、数字及特殊字符组成!'))
} else {
callback()
}
}