m-radio.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <template>
  2. <view @tap.native="clickRadio" :data-item="item" class="radio">
  3. <view :data-item="item" class="custom-icon" v-if="useIconSlot">{{
  4. name
  5. }}</view>
  6. <view :data-item="item" style="width: 8px"></view>
  7. <text :data-item="item">{{ item.value }}</text>
  8. </view>
  9. </template>
  10. <script>
  11. export default {
  12. data() {
  13. return {};
  14. },
  15. methods: {
  16. stopClick(e) {
  17. e.stopPropagation();
  18. },
  19. clickRadio(e) {
  20. console.log(e);
  21. this.$emit("clickRadio", e);
  22. e.stopPropagation();
  23. },
  24. },
  25. props: {
  26. useIconSlot: {
  27. type: Boolean,
  28. default: false,
  29. },
  30. name: {
  31. type: String,
  32. default: "",
  33. },
  34. item: {
  35. type: Object,
  36. default: () => {
  37. return {};
  38. },
  39. },
  40. },
  41. };
  42. </script>
  43. <style lang="scss" scoped>
  44. .radio {
  45. display: flex;
  46. align-content: center;
  47. align-items: center;
  48. padding: 8px 0;
  49. }
  50. .custom-icon {
  51. width: 75rpx;
  52. height: 75rpx;
  53. line-height: 75rpx;
  54. border-radius: 50%;
  55. text-align: center;
  56. overflow: hidden;
  57. background: #fff;
  58. box-shadow: 0px 4rpx 12rpx rgba(0, 0, 0, 0.16);
  59. }
  60. </style>