diff --git "a/qiun-data-charts\357\274\210uni-modules\357\274\211/uni_modules/qiun-data-charts/components/qiun-data-charts/qiun-data-charts.vue" "b/qiun-data-charts\357\274\210uni-modules\357\274\211/uni_modules/qiun-data-charts/components/qiun-data-charts/qiun-data-charts.vue" index dbcf19c1e4bbdb81c514706f31236e0b835dc6f0..82dbfec7e41bee98e746d809e2ef9b3bfebc0b8d 100644 --- "a/qiun-data-charts\357\274\210uni-modules\357\274\211/uni_modules/qiun-data-charts/components/qiun-data-charts/qiun-data-charts.vue" +++ "b/qiun-data-charts\357\274\210uni-modules\357\274\211/uni_modules/qiun-data-charts/components/qiun-data-charts/qiun-data-charts.vue" @@ -201,6 +201,31 @@ function getFormatDate(date) { } var lastMoveTime = null; +/** + * 防抖 + * + * @param {Object} fn 要执行的方法 + * @param {Object} wait 防抖多少秒 + * + * 在 vue 中使用(注意:不能使用箭头函数,否则this指向不对,并且不能再次封装如: + * move(){ // 错误调用方式 + * debounce(function () { + * console.log(this.title); + * }, 1000)}); + * 应该直接使用:() + * move: debounce(function () {// 正确调用方式 + * console.log(this.title); + * }, 1000) + */ +export function debounce(fn, wait) { + let timer; + return function() { + clearTimeout(timer); + timer = setTimeout(() => { + fn.apply(this, arguments); // 把参数传进去 + }, wait); + }; +} export default { name: 'qiun-data-charts', @@ -423,22 +448,24 @@ export default { this.beforeInit(); }) // #ifndef MP-ALIPAY || MP-BAIDU || MP-TOUTIAO || APP-PLUS - uni.onWindowResize(res => { - if (this.mixinDatacomLoading == true) { - return; - } - let errmsg = this.mixinDatacomErrorMessage - if(errmsg !== null && errmsg !== 'null' && errmsg !== ''){ - return; - } - setTimeout(() => { - if(this.echarts){ - this.echartsResize = !this.echartsResize - }else{ - this.resizeHandler() - } - }, 200); - }); + const time = this.inH5 ? 500 : 200; + const _this = this; + uni.onWindowResize( + debounce(function(res) { + if (_this.mixinDatacomLoading == true) { + return; + } + let errmsg = _this.mixinDatacomErrorMessage; + if (errmsg !== null && errmsg !== 'null' && errmsg !== '') { + return; + } + if (_this.echarts) { + _this.echartsResize = !_this.echartsResize; + } else { + _this.resizeHandler(); + } + }, time) + ); // #endif }, destroyed(){