兼兼街租房小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.0 KiB

  1. import Vue from 'vue';
  2. import App from './App';
  3. import request from '@/common/axios.js';
  4. import tokenUtil from '@/common/token.js';
  5. Vue.config.productionTip = false;
  6. Vue.prototype.$request = request;
  7. Vue.prototype.$tokenUtil = tokenUtil;
  8. Vue.prototype.$token = tokenUtil.token;
  9. Vue.prototype.$user = tokenUtil.user;
  10. /* 导入接口 */
  11. let api = require('./common/api');
  12. Vue.prototype.$api = api;
  13. // 方法
  14. import functions from './common/functions.js'
  15. Vue.prototype.$functions = functions
  16. Vue.mixin({
  17. methods: {
  18. setData: function(obj) {
  19. let that = this;
  20. let keys = [];
  21. let val, data;
  22. Object.keys(obj).forEach(function(key) {
  23. keys = key.split('.');
  24. val = obj[key];
  25. data = that.$data;
  26. keys.forEach(function(key2, index) {
  27. if (index + 1 == keys.length) {
  28. that.$set(data, key2, val);
  29. } else {
  30. if (!data[key2]) {
  31. that.$set(data, key2, {});
  32. }
  33. }
  34. data = data[key2];
  35. })
  36. });
  37. }
  38. }
  39. });
  40. App.mpType = 'app';
  41. const app = new Vue({
  42. ...App
  43. });
  44. app.$mount();