uni-grid-item.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. "use strict";
  2. const common_vendor = require("../../../../common/vendor.js");
  3. const _sfc_main = {
  4. name: "UniGridItem",
  5. inject: ["grid"],
  6. props: {
  7. index: {
  8. type: Number,
  9. default: 0
  10. }
  11. },
  12. data() {
  13. return {
  14. column: 0,
  15. showBorder: true,
  16. square: true,
  17. highlight: true,
  18. left: 0,
  19. top: 0,
  20. openNum: 2,
  21. width: 0,
  22. borderColor: "#e5e5e5"
  23. };
  24. },
  25. created() {
  26. this.column = this.grid.column;
  27. this.showBorder = this.grid.showBorder;
  28. this.square = this.grid.square;
  29. this.highlight = this.grid.highlight;
  30. this.top = this.hor === 0 ? this.grid.hor : this.hor;
  31. this.left = this.ver === 0 ? this.grid.ver : this.ver;
  32. this.borderColor = this.grid.borderColor;
  33. this.grid.children.push(this);
  34. this.width = this.grid.width;
  35. },
  36. beforeDestroy() {
  37. this.grid.children.forEach((item, index) => {
  38. if (item === this) {
  39. this.grid.children.splice(index, 1);
  40. }
  41. });
  42. },
  43. methods: {
  44. _onClick() {
  45. this.grid.change({
  46. detail: {
  47. index: this.index
  48. }
  49. });
  50. }
  51. }
  52. };
  53. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  54. return {
  55. a: $data.showBorder ? 1 : "",
  56. b: $data.showBorder && $props.index < $data.column ? 1 : "",
  57. c: $data.highlight ? 1 : "",
  58. d: $data.borderColor,
  59. e: $data.borderColor,
  60. f: $data.borderColor,
  61. g: common_vendor.o((...args) => $options._onClick && $options._onClick(...args)),
  62. h: common_vendor.s("width:" + $data.width + ";" + ($data.square ? "height:" + $data.width : ""))
  63. };
  64. }
  65. const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-7a807eb7"], ["__file", "D:/zx/mall-front-app/uni_modules/uni-grid/components/uni-grid-item/uni-grid-item.vue"]]);
  66. wx.createComponent(Component);