index.js 691 B

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