• JavaScript.import


    // --file.js--
    function getJSON(url, callback) {
      let xhr = new XMLHttpRequest();
      xhr.onload = function () { 
        callback(this.responseText) 
      };
      xhr.open("GET", url, true);
      xhr.send();
    }

    export function getUsefulContents(url, callback) {
      getJSON(url, data => callback(JSON.parse(data)));
    }

    // --main.js--
    import { getUsefulContents } from "file.js";
    getUsefulContents("http://www.example.com", data => {
      doSomethingUseful(data);
    });
  • 相关阅读:
    from import 的认识
    模块初识
    eq方法
    hash介绍
    item系列
    析构函数
    serializers进阶
    APIView源码解析
    RPC协议
    面试题补充
  • 原文地址:https://www.cnblogs.com/shidengyun/p/5439001.html
Copyright © 2020-2023  润新知