1、预览

image.png

2、实现

  1. <template>
  2. <div class="input-cell-wrapper" :style="inputSty">
  3. <div class="input-cell-inner">
  4. <span class="lable">{{ desc }}</span>
  5. <input
  6. class="input-sty"
  7. :disabled="disableInput"
  8. :value="value"
  9. :placeholder="defaultvalue"
  10. @input="input"
  11. />
  12. </div>
  13. </div>
  14. </template>
  15. <script>
  16. import Vue from 'vue';
  17. export default Vue.extend({
  18. name: 'InputCell',
  19. props: {
  20. inputSty: '',
  21. desc: '',
  22. disableInput: false,
  23. value: '',
  24. defaultvalue: '',
  25. },
  26. data: function () {
  27. return {};
  28. },
  29. methods: {
  30. input() {
  31. this.$emit('input', event.target.value);
  32. },
  33. },
  34. })
  35. </script>
  36. <style lang="scss" scoped>
  37. .input-cell-wrapper {
  38. height: 55px;
  39. background: #fff;
  40. display: flex;
  41. line-height: 55px;
  42. justify-content: space-between;
  43. padding: 0 15px;
  44. .input-cell-inner {
  45. width: 100%;
  46. border-bottom: solid 1px #e2e8f4;
  47. .lable {
  48. font-size: 15px;
  49. color: #1c222e;
  50. font-weight: 400;
  51. }
  52. .input-sty {
  53. width: 250px;
  54. text-align: right;
  55. font-size: 14px;
  56. border: 0;
  57. height: 100%;
  58. float: right;
  59. }
  60. .input-sty::-webkit-input-placeholder {
  61. color: #acb7ce;
  62. font-size: 14px;
  63. font-family: 'PingFang FC';
  64. }
  65. .input-sty:disabled {
  66. background: #fff;
  67. }
  68. .input-sty:focus{
  69. outline none;
  70. border 0;
  71. }
  72. }
  73. </style>

3、 使用

  1. import InputCell from './components/InputCell'
  2. ...
  3. components: {
  4. InputCell
  5. },
  6. ...
  7. <InputCell
  8. desc="设备类型"
  9. defaultvalue="输入设备类型"
  10. disableInput
  11. //:value="deviceType"
  12. v-model="deviceType"
  13. inputSty="margin-top: px"
  14. />