修改文件名称,去除多余代码,修改节流函数
This commit is contained in:
@@ -67,7 +67,7 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async fetchList(){
|
async fetchList(){
|
||||||
const { code,listData }= await this.$http.get("xx/xx/xx"x);
|
const { code, listData } = await this.$http.get("xx/xx/xx");
|
||||||
if(code === 200){
|
if(code === 200){
|
||||||
this.ListDataSelf = listData;
|
this.ListDataSelf = listData;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -258,9 +258,6 @@ export default {
|
|||||||
};
|
};
|
||||||
this.chart.setOption(option);
|
this.chart.setOption(option);
|
||||||
}
|
}
|
||||||
},
|
|
||||||
destroyed() {
|
|
||||||
window.onresize = null;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -393,12 +393,8 @@ export default {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
this.chart.setOption(option);
|
this.chart.setOption(option);
|
||||||
}
|
}
|
||||||
},
|
|
||||||
destroyed() {
|
|
||||||
window.onresize = null;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -94,9 +94,6 @@ export default {
|
|||||||
};
|
};
|
||||||
this.chart.setOption(option);
|
this.chart.setOption(option);
|
||||||
}
|
}
|
||||||
},
|
|
||||||
destroyed() {
|
|
||||||
window.onresize = null;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
-3
@@ -192,9 +192,6 @@ export default {
|
|||||||
};
|
};
|
||||||
this.chart.setOption(option);
|
this.chart.setOption(option);
|
||||||
}
|
}
|
||||||
},
|
|
||||||
destroyed() {
|
|
||||||
window.onresize = null;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
-3
@@ -153,9 +153,6 @@ export default {
|
|||||||
};
|
};
|
||||||
this.chart.setOption(option);
|
this.chart.setOption(option);
|
||||||
}
|
}
|
||||||
},
|
|
||||||
destroyed() {
|
|
||||||
window.onresize = null;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
+29
-40
@@ -1,35 +1,16 @@
|
|||||||
export function debounce(func, wait, immediate) {
|
/**
|
||||||
let timeout, args, context, timestamp, result;
|
* @param {Function} fn 函数
|
||||||
|
* @param {Number} delay 延迟时间
|
||||||
const later = function() {
|
*/
|
||||||
// 据上一次触发时间间隔
|
export function debounce(fn, delay) {
|
||||||
const last = +new Date() - timestamp;
|
var timer;
|
||||||
|
return function () {
|
||||||
// 上次被包装函数被调用时间间隔 last 小于设定时间间隔 wait
|
var context = this;
|
||||||
if (last < wait && last > 0) {
|
var args = arguments;
|
||||||
timeout = setTimeout(later, wait - last);
|
clearTimeout(timer);
|
||||||
} else {
|
timer = setTimeout(function () {
|
||||||
timeout = null;
|
fn.apply(context, args);
|
||||||
// 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用
|
}, delay);
|
||||||
if (!immediate) {
|
|
||||||
result = func.apply(context, args);
|
|
||||||
if (!timeout) context = args = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return function(...args) {
|
|
||||||
context = this;
|
|
||||||
timestamp = +new Date();
|
|
||||||
const callNow = immediate && !timeout;
|
|
||||||
// 如果延时不存在,重新设定延时
|
|
||||||
if (!timeout) timeout = setTimeout(later, wait);
|
|
||||||
if (callNow) {
|
|
||||||
result = func.apply(context, args);
|
|
||||||
context = args = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,9 +19,9 @@ export function debounce(func, wait, immediate) {
|
|||||||
* @param {String} fmt 需要转换的格式 如 yyyy-MM-dd、yyyy-MM-dd HH:mm:ss
|
* @param {String} fmt 需要转换的格式 如 yyyy-MM-dd、yyyy-MM-dd HH:mm:ss
|
||||||
*/
|
*/
|
||||||
export function formatTime(time, fmt) {
|
export function formatTime(time, fmt) {
|
||||||
if (!time) return ''
|
if (!time) return '';
|
||||||
else {
|
else {
|
||||||
const date = new Date(time)
|
const date = new Date(time);
|
||||||
const o = {
|
const o = {
|
||||||
'M+': date.getMonth() + 1,
|
'M+': date.getMonth() + 1,
|
||||||
'd+': date.getDate(),
|
'd+': date.getDate(),
|
||||||
@@ -48,15 +29,23 @@ export function formatTime(time, fmt) {
|
|||||||
'm+': date.getMinutes(),
|
'm+': date.getMinutes(),
|
||||||
's+': date.getSeconds(),
|
's+': date.getSeconds(),
|
||||||
'q+': Math.floor((date.getMonth() + 3) / 3),
|
'q+': Math.floor((date.getMonth() + 3) / 3),
|
||||||
'S': date.getMilliseconds()
|
S: date.getMilliseconds(),
|
||||||
}
|
};
|
||||||
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
|
if (/(y+)/.test(fmt))
|
||||||
|
fmt = fmt.replace(
|
||||||
|
RegExp.$1,
|
||||||
|
(date.getFullYear() + '').substr(4 - RegExp.$1.length)
|
||||||
|
);
|
||||||
for (const k in o) {
|
for (const k in o) {
|
||||||
if (new RegExp('(' + k + ')').test(fmt)) {
|
if (new RegExp('(' + k + ')').test(fmt)) {
|
||||||
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : ((
|
fmt = fmt.replace(
|
||||||
'00' + o[k]).substr(('' + o[k]).length)))
|
RegExp.$1,
|
||||||
|
RegExp.$1.length === 1
|
||||||
|
? o[k]
|
||||||
|
: ('00' + o[k]).substr(('' + o[k]).length)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fmt
|
return fmt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// 混入代码 resize-mixins.js
|
// 混入代码 resize-mixins.js
|
||||||
import { debounce } from '@/utils/index';
|
import { debounce } from '@/utils';
|
||||||
const resizeChartMethod = '$__resizeChartMethod';
|
const resizeChartMethod = '$__resizeChartMethod';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import CentreLeft1Chart from "@/components/echart/centerLeft2/centreLeft1Chart";
|
import CentreLeft1Chart from "@/components/echart/centerLeft/centreLeft1Chart";
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import CentreLeft2Chart from "@/components/echart/centerLeft2/centreLeft2Chart";
|
import CentreLeft2Chart from "@/components/echart/centerLeft/centreLeft2Chart";
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {};
|
return {};
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import centreRight2Chart1 from "@/components/echart/centerRight2/centerRight2Chart";
|
import centreRight2Chart1 from "@/components/echart/centerRight/centerRight2Chart";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
|
|||||||
Reference in New Issue
Block a user