add-popup.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <template>
  2. <u-popup v-model="show" mask mode="bottom" mask-close-able closeable border-radius="16" @close="close">
  3. <view class="inner">
  4. <view class="item" v-for="(item, index) in ops" :style="{ width: 100 / ops.length + '%' }" @click="chose(item, index)">
  5. <u-image width="100rpx" height="100rpx" :src="item.icon"></u-image>
  6. <view class="label">{{ item.label }}</view>
  7. </view>
  8. </view>
  9. </u-popup>
  10. </template>
  11. <script>
  12. export default {
  13. props: {
  14. // 配置项
  15. ops: {
  16. type: Array,
  17. default: () => {
  18. return [];
  19. }
  20. }
  21. },
  22. data() {
  23. return {
  24. show: false
  25. };
  26. },
  27. methods: {
  28. // 打开popup
  29. open() {
  30. this.show = true;
  31. },
  32. // 关闭
  33. close() {
  34. this.$emit('close');
  35. },
  36. // 选择
  37. chose(item, index) {
  38. if (item.type == 'page') {
  39. uni.navigateTo({
  40. url: item.url
  41. });
  42. }
  43. }
  44. }
  45. };
  46. </script>
  47. <style lang="scss" scoped>
  48. .inner {
  49. padding: 100rpx 30rpx 80rpx 30rpx;
  50. display: flex;
  51. align-items: center;
  52. justify-content: space-between;
  53. .item {
  54. display: flex;
  55. align-items: center;
  56. justify-content: center;
  57. flex-wrap: wrap;
  58. .label {
  59. margin-top: 16rpx;
  60. width: 100%;
  61. text-align: center;
  62. font-size: 26rpx;
  63. color: $app-theme-text-black-color;
  64. }
  65. }
  66. }
  67. </style>