1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
| <template>
| <view>
| <view class="main">
| <view class="inner1">{{desc}}</view>
| <view class="put inner2">
| <input class="p-input" type="text" :placeholder="placeholder" @input="input" v-model="data">
| <uni-icons class="p-icon" type="closeempty" size="16" color="#707070" v-show="data.length" @click="clear"></uni-icons>
| </view>
| <view class="inner3" v-show="btn">
| <button class="m-btn" size="mini">{{btnName}}</button>
| </view>
| </view>
| </view>
| </template>
|
| <script>
| export default {
| name:"z-input",
| data() {
| return {
| data:'',
| };
| },
| props: {
| desc: {
| type: String,
| default: ''
| },
| btn: {
| type: Boolean,
| default: false
| },
| btnName: {
| type: String,
| default: 'button'
| },
| placeholder: {
| type: String,
| default: '请输入'
| },
| value: {
| type: String,
| default: ''
| },
| lenCheck: {
| type: [Number],
| default: null
| },
| },
| watch: {
| data(val) {
| if (this.data.length != this.lenCheck) {
| console.log(123);
| this.data = val
| }
| this.$emit('input',val)
| },
| value(val) {
| this.data = val
| },
| },
| created() {
| this.data = this.value
| },
| methods: {
| input() {
|
| },
| clear() {
| this.data = ''
| }
| }
| }
| </script>
|
| <style scoped>
| .main {
| display: flex;
| align-items: center;
| min-height: 70rpx;
| background-color: #FFF;
| /* border-bottom: 1px solid darkgray; */
| }
| .put {
| display: flex;
| flex-shrink: 0;
| }
|
| .inner1 {
| width: 120rpx;
| padding-left: 8px;
| font-weight: 700;
| font-family:'Helvetica Neue';
| }
| .inner2 {
| background-color: aliceblue;
| flex: 1;
| display: flex;
| align-items: center;
| justify-content: center;
| }
| .p-input {
| flex:1;
| padding-left: 8px;
| }
| .p-icon {
| margin-left: 8px;
| margin-right: 8px;
| }
| .inner3 {
| width: 200rpx;
| display: flex;
| align-items: center;
| justify-content: center;
| }
| .m-btn {
| background-color: #3c9cff;
| color: #FFF;
| }
| .m-btn:active {
| background-color: #55bbff;
| color: #FFF;
| }
|
| </style>
|
|