From 263a55b260528a6e81f08e0e9511601c62f6946a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E5=A4=A9?= Date: Thu, 4 Jul 2019 12:01:21 +0800 Subject: [PATCH] update --- src/datepicker/index.js | 46 +++++++++++++++++++---------------------- src/request/index.js | 10 +++++++-- 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/src/datepicker/index.js b/src/datepicker/index.js index 2eff499..787a267 100644 --- a/src/datepicker/index.js +++ b/src/datepicker/index.js @@ -138,46 +138,42 @@ export default Anot.component('datepicker', { //获取初始值 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 (!Date.isDate(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 (!Date.isDate(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 } - 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 = { year: defVal.getFullYear(), month: defVal.getMonth() + 1, diff --git a/src/request/index.js b/src/request/index.js index 286c8ae..4b4c84b 100644 --- a/src/request/index.js +++ b/src/request/index.js @@ -18,7 +18,7 @@ const noop = function(e, res) { let isLocal = false try { - isLocal = rlocalProtocol.test(location.ptyperotocol) + isLocal = rlocalProtocol.test(location.protocol) } catch (e) {} let originAnchor = document.createElement('a') @@ -68,7 +68,13 @@ class _Request { } // 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()