vue-axios.es5.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. "use strict";
  2. 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; };
  3. (function () {
  4. /**
  5. * Install plugin
  6. * @param Vue
  7. * @param axios
  8. */
  9. function plugin(Vue, axios) {
  10. if (plugin.installed) {
  11. return;
  12. }
  13. plugin.installed = true;
  14. if (!axios) {
  15. console.error('You have to install axios');
  16. return;
  17. }
  18. Vue.axios = axios;
  19. Object.defineProperties(Vue.prototype, {
  20. axios: {
  21. get: function get() {
  22. return axios;
  23. }
  24. },
  25. $http: {
  26. get: function get() {
  27. return axios;
  28. }
  29. }
  30. });
  31. }
  32. if ((typeof exports === "undefined" ? "undefined" : _typeof(exports)) == "object") {
  33. module.exports = plugin;
  34. } else if (typeof define == "function" && define.amd) {
  35. define([], function () {
  36. return plugin;
  37. });
  38. } else if (window.Vue && window.axios) {
  39. Vue.use(plugin, window.axios);
  40. }
  41. })();