quanwei
2025-11-21 2d9362ae6f528f57e6133d5d80f0b633c24e8eb6
1
2
3
4
5
6
7
8
9
10
11
12
/*封装获取远程JS返回的JSON数据*/
export const getJson = (url, func, callback) => {
  window[func] = function(data) {
    callback(data);
  };
  let script = document.createElement('script');
  script.setAttribute('src', url);
  document.getElementsByTagName('head')[0].appendChild(script);
  script.onload = script.onreadystatechange = function(data) {
    window[func] = null;
  };
}