gui-radio.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <view
  3. class="gui-flex gui-row gui-nowrap gui-align-items-center"
  4. @tap.stop="changeStatus">
  5. <text
  6. v-if="status"
  7. class="gui-icons gui-block gui-text-center"
  8. :class="checkedClass"
  9. :style="{
  10. width : size+'rpx',
  11. height : size+'rpx',
  12. lineHeight:size+'rpx',
  13. fontSize:(size-15)+'rpx',
  14. borderRadius:(size)+'rpx'
  15. }">&#xe60f;</text>
  16. <text v-else
  17. class="gui-icons gui-block gui-text-center"
  18. :class="defaultClass"
  19. :style="{
  20. width : size+'rpx',
  21. height : size+'rpx',
  22. lineHeight:(size+2)+'rpx',
  23. fontSize:(size - 8)+'rpx',
  24. }">&#xe762;</text>
  25. <view
  26. class="gui-radio-lable gui-flex1">
  27. <slot></slot>
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. export default {
  33. name : "gui-radio",
  34. props : {
  35. size : {
  36. type : Number,
  37. default : 38
  38. },
  39. defaultClass : {
  40. type : Array,
  41. default : function(){
  42. return ['gui-color-gray']
  43. }
  44. },
  45. checked : {
  46. type : Boolean,
  47. default : false
  48. },
  49. checkedClass : {
  50. type : Array,
  51. default : function(){
  52. return ['gui-bg-primary', 'gui-color-white']
  53. }
  54. },
  55. parameter : {
  56. type : Array,
  57. default : function () {
  58. return []
  59. }
  60. },
  61. },
  62. data() {
  63. return {
  64. status : false
  65. }
  66. },
  67. watch: {
  68. checked : function (val, old) {
  69. this.status = val;
  70. }
  71. },
  72. created : function(){
  73. this.status = this.checked;
  74. },
  75. methods:{
  76. changeStatus : function(){
  77. this.status = !this.status;
  78. this.$emit('change', [this.status, this.parameter]);
  79. }
  80. },
  81. emits : ['change']
  82. }
  83. </script>
  84. <style scoped>
  85. .gui-radio-lable{margin-left:15rpx; width:100rpx;}
  86. </style>