Input.vue 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <template>
  2. <div class="inp-wrap">
  3. <input :type="item.controlType==6?'text':'number'"
  4. :class="{'change':borColor}"
  5. v-model="val"
  6. @input="changeVal"
  7. @blur="blur">
  8. </div>
  9. </template>
  10. <script type="text/javascript">
  11. export default {
  12. name:'Input',
  13. data(){
  14. return{
  15. msg:"输入框",
  16. val: this.item.value || '',
  17. borColor:false
  18. }
  19. },
  20. props:['item'],
  21. methods:{
  22. changeVal(){
  23. this.borColor = true;
  24. },
  25. blur(){
  26. this.borColor = false;
  27. const newData = Object.assign({},this.item,{value:this.val});
  28. this.$emit("updata",newData);
  29. }
  30. },
  31. watch:{
  32. item:{
  33. handler(newVal,oldVal){
  34. this.val = newVal.value;
  35. },
  36. deep:true
  37. }
  38. }
  39. }
  40. </script>
  41. <style lang="less" scoped>
  42. .inp-wrap{
  43. input{
  44. width: 100%;
  45. color: #4F50FF;
  46. font-size: .3rem;
  47. border: 0 none;
  48. // border-bottom: 1px solid #7C828E;
  49. border-bottom: 1px solid #DFE0E4;
  50. margin-bottom: .3rem;
  51. border-radius: 0;
  52. outline-color: invert;
  53. padding-left: 0.1rem;
  54. box-sizing: border-box;
  55. background: transparent;
  56. }
  57. .change{
  58. border-color: #4F50FF;
  59. }
  60. }
  61. </style>