// 动态加载script的方法
function loadJs(src) {
  var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
    async = _ref.async,
    charset = _ref.charset,
    text = _ref.text,
    type = _ref.type,
    id = _ref.id,
    defer = _ref.defer,
    crossorigin = _ref.crossorigin,
    integrity = _ref.integrity,
    referrerPolicy = _ref.referrerPolicy,
    fail = _ref.fail,
    success = _ref.success;
  var attrs = {};
  if (id) attrs.id = id;
  if (defer) attrs.defer = defer;
  if (crossorigin) attrs.crossorigin = crossorigin;
  if (integrity) attrs.integrity = integrity;
  if (referrerPolicy) attrs.referrerPolicy = referrerPolicy;
  return new Promise(function (resolve) {
    var loadScript = require("./loadscript.js");
    loadScript(src, {
      async: async,
      charset: charset,
      text: text,
      type: type,
      attrs: attrs
    }, function (error, script) {
      if (error) {
        resolve(null);
        if (typeof fail === 'function') fail();
      } else {
        resolve(script);
        if (typeof success === 'function') success(script);
      }
    });
  });
}
export default loadJs;