uni-icons.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. "use strict";
  2. const uni_modules_uniIcons_components_uniIcons_icons = require("./icons.js");
  3. const common_vendor = require("../../../../common/vendor.js");
  4. const getVal = (val) => {
  5. const reg = /^[0-9]*$/g;
  6. return typeof val === "number" || reg.test(val) ? val + "px" : val;
  7. };
  8. const _sfc_main = {
  9. name: "UniIcons",
  10. emits: ["click"],
  11. props: {
  12. type: {
  13. type: String,
  14. default: ""
  15. },
  16. color: {
  17. type: String,
  18. default: "#333333"
  19. },
  20. size: {
  21. type: [Number, String],
  22. default: 16
  23. },
  24. customPrefix: {
  25. type: String,
  26. default: ""
  27. }
  28. },
  29. data() {
  30. return {
  31. icons: uni_modules_uniIcons_components_uniIcons_icons.icons.glyphs
  32. };
  33. },
  34. computed: {
  35. unicode() {
  36. let code = this.icons.find((v) => v.font_class === this.type);
  37. if (code) {
  38. return unescape(`%u${code.unicode}`);
  39. }
  40. return "";
  41. },
  42. iconSize() {
  43. return getVal(this.size);
  44. }
  45. },
  46. methods: {
  47. _onClick() {
  48. this.$emit("click");
  49. }
  50. }
  51. };
  52. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  53. return {
  54. a: $props.color,
  55. b: $options.iconSize,
  56. c: common_vendor.n("uniui-" + $props.type),
  57. d: common_vendor.n($props.customPrefix),
  58. e: common_vendor.n($props.customPrefix ? $props.type : ""),
  59. f: common_vendor.o((...args) => $options._onClick && $options._onClick(...args))
  60. };
  61. }
  62. const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "/Users/RuHu.Xu/Desktop/mall-newfeifan-zx-app/uni_modules/uni-icons/components/uni-icons/uni-icons.vue"]]);
  63. wx.createComponent(Component);