| 12345678910111213141516171819202122232425262728 |
- // 防抖函数
- function debounce(func, wait) {
- let timeout;
- return function (...args) { // 使用剩余参数语法接收所有传入的参数
- clearTimeout(timeout); // 清除上一个定时器
- timeout = setTimeout(() => {
- func.apply(this, args); // 使用apply来调用原始函数,并传入当前this值和所有参数
- }, wait);
- };
- }
- // 获取页面元素
- const getElement = (id) => {
- const element = echarts.init(
- document.getElementById(id)
- );
- return element
- }
- // 获取url参数
- const getQueryString = () => {
- let urlStr = window.location.href.split("?")[1];
- const urlSearchParams = new URLSearchParams(urlStr);
- const result = Object.fromEntries(urlSearchParams.entries());
- return result;
- }
|