graceCheckBtn.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <template>
  2. <view class="grace-nowrap grace-flex-vcenter" :style="{width:width}" @tap.stop="changeStatus">
  3. <view
  4. :class="['grace-check-btn grace-icons', status ? 'grace-check-checked' : '']"
  5. :style="{fontSize:size+'rpx', lineHeight:size+'rpx', color : status ? checkedColor : color}"></view>
  6. <view class="grace-check-lable"><slot></slot></view>
  7. </view>
  8. </template>
  9. <script>
  10. export default {
  11. props: {
  12. width:{
  13. type:String,
  14. default:'100%'
  15. },
  16. size : {
  17. type : Number,
  18. default : 38
  19. },
  20. color : {
  21. type : String,
  22. default : '#EEEEEE'
  23. },
  24. checked : {
  25. type : Boolean,
  26. default : false
  27. },
  28. checkedColor : {
  29. type : String,
  30. default : '#FF0036'
  31. },
  32. parameter : {
  33. type : Array,
  34. default : function () {
  35. return []
  36. }
  37. }
  38. },
  39. data() {
  40. return {
  41. status : false
  42. }
  43. },
  44. watch: {
  45. checked : function (val, old) {
  46. this.status = val;
  47. }
  48. },
  49. created : function(){
  50. this.status = this.checked;
  51. },
  52. methods:{
  53. changeStatus : function(){
  54. this.status = !this.status;
  55. this.$emit('change', [this.status, this.parameter]);
  56. }
  57. }
  58. }
  59. </script>
  60. <style scoped>
  61. .grace-check-btn{color:#999999; flex-shrink:0;}
  62. .grace-check-btn:after{content:"\e762";}
  63. .grace-check-checked:after{content:"\e7f8";}
  64. .grace-check-lable{color:#555555; margin-left:20rpx; font-size:26rpx; width:700rpx;}
  65. </style>