This repository has been archived on 2023-08-30. You can view files and clone it, but cannot push or open issues/pull-requests.
bytedo
/
wcui
Archived
1
0
Fork 0
old
宇天 2019-07-04 12:01:21 +08:00
parent b417c19e22
commit 263a55b260
2 changed files with 29 additions and 27 deletions

View File

@ -138,46 +138,42 @@ export default Anot.component('datepicker', {
//获取初始值 //获取初始值
let defVal = state.value || null let defVal = state.value || null
if (!defVal) {
if (props.minDate) {
defVal = props.minDate
} else if (props.maxDate) {
defVal = props.maxDate
}
}
// 修正默认值, 如果不是Date对象, 则转为Date对象
if (defVal) {
if (!Date.isDate(defVal)) {
defVal = new Date(defVal)
}
} else {
defVal = new Date()
}
if (props.minDate) { if (props.minDate) {
if (!Date.isDate(props.minDate)) { if (!Date.isDate(props.minDate)) {
props.minDate = new Date(props.minDate) props.minDate = new Date(props.minDate)
} }
if (defVal <= props.minDate) {
defVal = props.minDate
}
state.min.year = props.minDate.getFullYear()
state.min.month = props.minDate.getMonth() + 1
state.min.day = props.minDate.getDate()
} }
if (props.maxDate) { if (props.maxDate) {
if (!Date.isDate(props.maxDate)) { if (!Date.isDate(props.maxDate)) {
props.maxDate = new Date(props.maxDate) props.maxDate = new Date(props.maxDate)
} }
if (defVal >= props.maxDate) { }
if (defVal) {
// 修正默认值, 如果不是Date对象, 则转为Date对象
if (!Date.isDate(defVal)) {
defVal = new Date(defVal)
}
} else {
defVal = new Date()
if (props.minDate && defVal < props.minDate) {
defVal = props.minDate
}
if (props.maxDate && defVal > props.maxDate) {
defVal = props.maxDate defVal = props.maxDate
} }
state.max.year = props.maxDate.getFullYear()
state.max.month = props.maxDate.getMonth() + 1
state.max.day = props.maxDate.getDate()
} }
state.min.year = props.minDate.getFullYear()
state.min.month = props.minDate.getMonth() + 1
state.min.day = props.minDate.getDate()
state.max.year = props.maxDate.getFullYear()
state.max.month = props.maxDate.getMonth() + 1
state.max.day = props.maxDate.getDate()
state.last = { state.last = {
year: defVal.getFullYear(), year: defVal.getFullYear(),
month: defVal.getMonth() + 1, month: defVal.getMonth() + 1,

View File

@ -18,7 +18,7 @@ const noop = function(e, res) {
let isLocal = false let isLocal = false
try { try {
isLocal = rlocalProtocol.test(location.ptyperotocol) isLocal = rlocalProtocol.test(location.protocol)
} catch (e) {} } catch (e) {}
let originAnchor = document.createElement('a') let originAnchor = document.createElement('a')
@ -68,7 +68,13 @@ class _Request {
} }
// url规范化 // url规范化
url = url.replace(/#.*$/, '').replace(/^\/\//, location.protocol + '//') url = url.replace(/#.*$/, '')
if (request.BASE_URL) {
if (!/^([a-z]+:|\/\/)/.test(url)) {
url = request.BASE_URL + url
}
}
method = method.toUpperCase() method = method.toUpperCase()