微信

index.vue 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template>
  2. <div class="radio">
  3. <a v-for="(item,index) in data" :key="index" :class="{'active': item.id === value}" @click="cut(item)">{{item.value}}</a>
  4. </div>
  5. </template>
  6. <script>
  7. export default {
  8. name: '',
  9. props: ['data', 'value', 'disabled'],
  10. data () {
  11. return {
  12. }
  13. },
  14. created () {
  15. },
  16. methods: {
  17. cut (item) {
  18. if (!this.disabled) {
  19. this.$emit('input', item.id)
  20. }
  21. }
  22. }
  23. }
  24. </script>
  25. <!-- Add "scoped" attribute to limit CSS to this component only -->
  26. <style lang="scss" scoped>
  27. .radio {
  28. font-size: 0;
  29. white-space: nowrap;
  30. > * {
  31. display: block;
  32. font-size: 0.15rem;
  33. position: relative;
  34. padding-left: 0.25rem;
  35. color: #a1a1a1;
  36. margin-left: 0.5rem;
  37. line-height: .3rem;
  38. &::after {
  39. content: "";
  40. width: 0.14rem;
  41. height: 0.14rem;
  42. position: absolute;
  43. left: 0;
  44. top: 50%;
  45. transform: translateY(-50%);
  46. -webkit-transform: translateY(-50%);
  47. border-radius: 100%;
  48. border: 0.01rem solid #fc6243;
  49. z-index: 1;
  50. }
  51. &.active::before {
  52. content: "";
  53. width: 0.08rem;
  54. height: 0.08rem;
  55. position: absolute;
  56. left: 0.04rem;
  57. top: 50%;
  58. transform: translateY(-50%);
  59. -webkit-transform: translateY(-50%);
  60. border-radius: 100%;
  61. background: #fc6243;
  62. z-index: 2;
  63. }
  64. }
  65. }
  66. </style>