Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 
 

78 rindas
1.7 KiB

  1. /*
  2. Learun-MPUI
  3. 力软框架小程序 UI 库 (uni-app 专用)
  4. 在项目中使用本 UI 库,需要以下三个步骤:
  5. 1、将本项目文件夹放置在 /components/ 内;
  6. 2、在 /main.js 中添加以下内容,以导入 mixins 和 CSS:
  7. import '@/components/learun-mpui'
  8. 3、在 /pages.json 中添加以下内容,以引入组件:
  9. "easycom": {
  10. "custom": {
  11. // #ifdef MP-ALIPAY
  12. "l-(.+)": "@/components/learun-ui-ali/$1.vue",
  13. // #endif
  14. // #ifndef MP-ALIPAY
  15. "l-(.*)": "@/components/learun-ui-wx/$1.vue",
  16. // #endif
  17. "-": "-"
  18. }
  19. }
  20. */
  21. import Vue from 'vue'
  22. import uiIcons from './icons.js'
  23. import uiColors from './colors.js'
  24. // 现在 CSS 必须在 <style> 中引入,参考:https://ask.dcloud.net.cn/question/86907
  25. // 等待 uni-app 后续升级后可以解除下行代码的注释
  26. // import './styles/index.css'
  27. const mixins = {
  28. props: {
  29. // #ifdef MP-ALIPAY
  30. style: { default: '' },
  31. className: { default: '' },
  32. // #endif
  33. },
  34. methods: {
  35. getStyle(style) {
  36. const styleHelper = t => {
  37. if (!t) { return '' }
  38. return typeof t === 'object' ?
  39. Object.entries(t).map(([k, v]) => v ? `${k.replace(/([A-Z])/g,"-$1").toLowerCase()}: ${v}; ` : '') :
  40. '' + t
  41. }
  42. return styleHelper(this.style) + styleHelper(style)
  43. },
  44. getColor(colorStr, defaultValue = null) {
  45. if (colorStr.startsWith('#')) {
  46. return colorStr
  47. }
  48. const result = this.colors.find(t => t.color === colorStr)
  49. return result ? result.name : defaultValue
  50. },
  51. getUiIcons() {
  52. return uiIcons
  53. },
  54. getUiColors() {
  55. return uiColors
  56. }
  57. }
  58. }
  59. Vue.mixin(mixins)