猫妈狗爸伴宠师小程序后端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.3 KiB

7 months ago
  1. <template lang="pug">
  2. .number-range-wrapper
  3. el-input.start(:value="value1[0]" @input="changeVal(0, $event)" placeholder="起始值")
  4. .c-line
  5. span -
  6. el-input.end(:value="value1[1]" @input="changeVal(1, $event)" placeholder="结束值")
  7. </template>
  8. <script>
  9. export default {
  10. name: 'NumberRange',
  11. props: {
  12. value: {
  13. type: Array,
  14. default: []
  15. }
  16. },
  17. computed: {
  18. value1: {
  19. get() {
  20. return this.value || []
  21. },
  22. set(v) {
  23. this.$emit('input', v);
  24. }
  25. }
  26. },
  27. methods: {
  28. changeVal(idx, v) {
  29. const val = [...this.value1];
  30. val[idx] = v ? Number(v) : null;
  31. this.value1 = val;
  32. }
  33. }
  34. }
  35. </script>
  36. <style lang="stylus">
  37. .number-range-wrapper
  38. max-width 240px
  39. display inline-flex
  40. align-items stretch
  41. line-height 1
  42. .c-line
  43. border-top 1px solid #DCDFE6
  44. border-bottom 1px solid #DCDFE6
  45. padding 0 8px
  46. margin 0 -1px
  47. color #DCDFE6
  48. z-index 1
  49. background-color white
  50. display inline-flex
  51. align-items center
  52. user-select none
  53. .start
  54. .el-input__inner
  55. border-top-right-radius 0!important
  56. border-bottom-right-radius 0!important
  57. &:hover
  58. z-index 2
  59. .end
  60. .el-input__inner
  61. border-top-left-radius 0!important
  62. border-bottom-left-radius 0!important
  63. &:hover
  64. z-index 2
  65. </style>