en-radio.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <template>
  2. <view class="row-justify-sb center p-tb30 bor-bottom-1 size-28">
  3. <view class="wh-text"><text>{{name}}</text></view>
  4. <view class="row-c">
  5. <view class="row-c radiu-item m-l20" :class="{'active-radiu':radioValue === item.value}"
  6. v-for="(item,index) in list" :key="index" @click="onSelect(item.value)">
  7. <image class="wh-30 m-r20"
  8. :src="radioValue == item.value?'/static/img/information/correct.png':'/static/img/information/error.png'"
  9. mode="aspectFill"></image>
  10. <text>{{item.text}}</text>
  11. </view>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. export default {
  17. props: {
  18. name: {
  19. type: String,
  20. default: ''
  21. },
  22. value: {
  23. type: Number,
  24. default: 0
  25. },
  26. list: {
  27. type: Array,
  28. default: () => []
  29. }
  30. },
  31. watch: {
  32. value: {
  33. handler(value) {
  34. this.radioValue = value
  35. },
  36. immediate: true
  37. },
  38. },
  39. data() {
  40. return {
  41. radioValue: 0
  42. }
  43. },
  44. methods: {
  45. onSelect(value) {
  46. this.radioValue = value
  47. this.$emit('onSelect', value)
  48. }
  49. }
  50. }
  51. </script>
  52. <style lang="scss" scoped>
  53. .wh-text {
  54. width: 110rpx;
  55. text-align: justify;
  56. text-align-last: justify;
  57. vertical-align: top;
  58. height: 38rpx;
  59. }
  60. .wh-text:after {
  61. content: '';
  62. width: 110rpx;
  63. height: 0;
  64. display: inline-block;
  65. overflow: hidden;
  66. }
  67. .radiu-item {
  68. width: 140rpx;
  69. padding: 6rpx 16rpx;
  70. border-radius: 100rpx;
  71. border: 1rpx solid #CCCCCC;
  72. }
  73. .active-radiu {
  74. color: #0FB160;
  75. border: 1rpx solid #0FB160;
  76. }
  77. </style>