|
|
@@ -8,22 +8,27 @@ const coinTop50 = {
|
|
|
items: [],
|
|
|
rangeDate:RANGE_MAX,
|
|
|
maxRange:RANGE_MAX,
|
|
|
+ source:axios.CancelToken.source(),
|
|
|
datepicker:null
|
|
|
}
|
|
|
},
|
|
|
+ created(){
|
|
|
+ this.requestData = _.throttle(this.requestData,500)
|
|
|
+ },
|
|
|
mounted() {
|
|
|
this.requestData(this.date)
|
|
|
const elems = document.querySelectorAll('.datepicker');
|
|
|
this.datepicker = M.Datepicker.init(elems, {onClose:()=>{
|
|
|
this.date = this.datepicker.date.toISOString().slice(0,10)
|
|
|
}})[0];
|
|
|
+
|
|
|
},
|
|
|
watch:{
|
|
|
date(newDate,oldDate){
|
|
|
this.requestData(newDate)
|
|
|
},
|
|
|
rangeDate(newValue){
|
|
|
- this.date = MIN_DATE.add(newValue,"d").format("YYYY-MM-DD");
|
|
|
+ this.date = MIN_DATE.add(newValue,"d").format("YYYY-MM-DD");
|
|
|
}
|
|
|
},
|
|
|
methods:{
|
|
|
@@ -32,6 +37,13 @@ const coinTop50 = {
|
|
|
const url = `/top50json/${d.getDate()}-${("0"+(d.getMonth()+1)).slice(-2)}-${d.getFullYear()}/`;
|
|
|
axios.get(url)
|
|
|
.then(this.handleJsonUpdate)
|
|
|
+ .catch(function (thrown) {
|
|
|
+ if (axios.isCancel(thrown)) {
|
|
|
+ console.log('Request canceled', thrown.message);
|
|
|
+ } else {
|
|
|
+ console.log(thrown)
|
|
|
+ }
|
|
|
+ });
|
|
|
},
|
|
|
handleJsonUpdate(response){
|
|
|
this.items = response.data
|