add between to Number
created () {
/* eslint-disable no-extend-native */
Number.prototype.between = function (a, b) {
let inclusive = true
let min = Math.min(a, b)
let max = Math.max(a, b)
return inclusive ? this >= min && this <= max : this > min && this < max
}
},
保留锚点的下划线,又不跳转
href="javascript:void(func)"
禁用浏览器后退
window.addEventListener('popstate', (e) => {
window.history.forward(1)
history.pushState(null, null, document.URL)
})
导出Excel
export function download (url, options) {
let form = $('<form>')
form.attr('style', 'display:none')
form.attr('target', '')
form.attr('method', 'post')
form.attr('action', url)
let tokenInput = $('<input>')
let typeInput = $('<input>')
tokenInput.attr('type', 'hidden')
tokenInput.attr('name', 'token')
tokenInput.attr('value', localStorage.getItem('default_auth_token'))
typeInput.attr('type', 'hidden')
typeInput.attr('name', 'options')
typeInput.attr('value', JSON.stringify(options))
$('body').append(form)
form.append(tokenInput)
form.append(typeInput)
form.submit()
}
导入懒加载
const UserCenter = () => import('components/user-center/user-center')
网友评论