兼兼街租房小程序
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.

53 lines
1.1 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. // 引入全局uView
  11. import uView from 'uview-ui'
  12. Vue.use(uView);
  13. /* 导入接口 */
  14. let api = require('./common/api');
  15. Vue.prototype.$api = api;
  16. // 方法
  17. import functions from './common/functions.js'
  18. Vue.prototype.$functions = functions
  19. Vue.mixin({
  20. methods: {
  21. setData: function(obj) {
  22. let that = this;
  23. let keys = [];
  24. let val, data;
  25. Object.keys(obj).forEach(function(key) {
  26. keys = key.split('.');
  27. val = obj[key];
  28. data = that.$data;
  29. keys.forEach(function(key2, index) {
  30. if (index + 1 == keys.length) {
  31. that.$set(data, key2, val);
  32. } else {
  33. if (!data[key2]) {
  34. that.$set(data, key2, {});
  35. }
  36. }
  37. data = data[key2];
  38. })
  39. });
  40. }
  41. }
  42. });
  43. App.mpType = 'app';
  44. const app = new Vue({
  45. ...App
  46. });
  47. app.$mount();