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;
| };
| }
|
|