initialize - 副本.js 924 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // 模型数据读取
  2. import {
  3. registerGlobalAsyncComponents
  4. } from "./injectModule"
  5. import {
  6. getStyle,
  7. getSingleStyle,
  8. unit
  9. } from "./styles"
  10. export default {
  11. install(Vue) {
  12. // 注册公共模板
  13. registerGlobalAsyncComponents(Vue)
  14. Vue.prototype.$getStyle = getStyle;
  15. Vue.prototype.$getSingleStyle = getSingleStyle;
  16. Vue.prototype.$unit = unit;
  17. Object.defineProperty(Vue.prototype, '$getConfigVal', {
  18. value: (attrsConfig, key) => {
  19. let value = '';
  20. try {
  21. value = attrsConfig[key].value
  22. } catch (e) {
  23. //TODO handle the exception
  24. }
  25. return value
  26. }
  27. });
  28. Object.defineProperty(Vue.prototype, '$getObjectVal', {
  29. value: (ObjectList) => {
  30. const obj = {};
  31. try {
  32. if (ObjectList) {
  33. for (let key in ObjectList) {
  34. obj[key] = ObjectList[key].value
  35. }
  36. }
  37. } catch (e) {
  38. //TODO handle the exception
  39. }
  40. return obj
  41. }
  42. })
  43. }
  44. }