Commit d076a3ee authored by chenghong_tao's avatar chenghong_tao

增加防抖函数

parent a79026df
......@@ -62,9 +62,9 @@ md.use((md) => {
myChart.setOption(option);
// 监听窗口大小变化事件
const resizeHandler = () => {
const resizeHandler = debounce(() => {
myChart.resize();
};
}, 300); // 调整延迟时间
window.addEventListener("resize", resizeHandler);
// 清理事件监听器
......@@ -89,6 +89,15 @@ md.use((md) => {
const renderedContent = computed(() => {
return md.render(props.content);
});
// 自定义防抖函数
function debounce(func, wait) {
let timeout;
return function(...args) {
clearTimeout(timeout);
timeout = setTimeout(() => func.apply(this, args), wait);
};
}
</script>
<style lang="less" scoped>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment