UNPKG

vue-frisbee

Version:

A small wrapper for integrating frisbee to Vuejs

50 lines (42 loc) 1.45 kB
'use strict'; var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; (function () { /** * Install plugin * @param Vue * @param Frisbee * @param opts */ var plugin = function plugin(Vue, Frisbee) { var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; if (plugin.installed) { return; } plugin.installed = true; if (!Frisbee) { console.error('You have to install Frisbee'); return; } // Only apply auto base if in browser if (window) { if (!opts.baseURI || opts.baseURI.trim() === '') { var base = document.getElementsByTagName('base')[0].getAttribute('href'); opts.baseURI = base || window.location.href; } } var frisbee = new Frisbee(opts); Vue.Frisbee = frisbee; Vue.prototype.Frisbee = frisbee; Vue.$http = frisbee; Vue.prototype.$http = frisbee; }; if ((typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) === 'object') { module.exports = plugin; } else if (typeof define === 'function' && define.amd) { define([], function () { return plugin; }); } else if (window.Vue && window.Frisbee) { Vue.use(plugin, window.Frisbee); } })();