Skip to content

Commit c85d8a5

Browse files
committed
style: input demo
1 parent f4a8d29 commit c85d8a5

1 file changed

Lines changed: 27 additions & 24 deletions

File tree

pages/component/input/input.vue

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,18 @@
1616
</view>
1717
<view class="uni-form-item uni-column">
1818
<view class="title">实时获取输入值:{{inputValue}}</view>
19-
<input class="uni-input" @input="bindKeyInput" placeholder="输入同步到view中" />
19+
<input class="uni-input" @input="onKeyInput" placeholder="输入同步到view中" />
2020
</view>
2121
<view class="uni-form-item uni-column">
2222
<view class="title">控制输入的input</view>
23-
<input class="uni-input" @input="bindReplaceInput" v-model="changeValue" placeholder="连续的两个1会变成2" />
23+
<input class="uni-input" @input="replaceInput" v-model="changeValue" placeholder="连续的两个1会变成2" />
2424
</view>
25+
<!-- #ifndef MP-BAIDU -->
2526
<view class="uni-form-item uni-column">
2627
<view class="title">控制键盘的input</view>
27-
<input class="uni-input" ref="input1" @input="bindHideKeyboard" placeholder="输入123自动收起键盘" />
28+
<input class="uni-input" ref="input1" @input="hideKeyboard" placeholder="输入123自动收起键盘" />
2829
</view>
30+
<!-- #endif -->
2931
<view class="uni-form-item uni-column">
3032
<view class="title">数字输入的input</view>
3133
<input class="uni-input" type="number" placeholder="这是一个数字输入框" />
@@ -49,7 +51,7 @@
4951
<view class="uni-form-item uni-column">
5052
<view class="title">带清除按钮的输入框</view>
5153
<view class="with-fun">
52-
<input class="uni-input" placeholder="带清除按钮的输入框" :value="inputClearValue" @input="bindClearInput" />
54+
<input class="uni-input" placeholder="带清除按钮的输入框" :value="inputClearValue" @input="clearInput" />
5355
<view class="uni-icon uni-icon-clear" v-if="showClearIcon" @click="clearIcon"></view>
5456
</view>
5557
</view>
@@ -71,47 +73,48 @@
7173
focus: false,
7274
inputValue: '',
7375
showClearIcon: false,
74-
inputClearValue: "",
75-
changeValue:"",
76+
inputClearValue: '',
77+
changeValue: '',
7678
showPassword: true,
77-
src: "../../../static/eye-1.png"
79+
src: '../../../static/eye-1.png'
7880
}
7981
},
8082
methods: {
81-
bindKeyInput: function (e) {
82-
this.inputValue = e.target.value
83+
onKeyInput: function(event) {
84+
this.inputValue = event.target.value
8385
},
84-
bindReplaceInput: function (e) {
85-
var value = e.target.value;
86-
if(value === '11'){
87-
this.changeValue = "2";
86+
replaceInput: function(event) {
87+
var value = event.target.value;
88+
if (value === '11') {
89+
this.changeValue = '2';
8890
}
8991
},
90-
bindHideKeyboard: function (e) {
91-
if (e.target.value === '123') {
92-
// 收起键盘
92+
hideKeyboard: function(event) {
93+
if (event.target.value === '123') {
9394
uni.hideKeyboard();
9495
}
9596
},
96-
bindClearInput: function (e) {
97-
this.inputClearValue = e.target.value;
98-
if (e.target.value.length > 0) {
97+
clearInput: function(event) {
98+
this.inputClearValue = event.target.value;
99+
if (event.target.value.length > 0) {
99100
this.showClearIcon = true;
100101
} else {
101102
this.showClearIcon = false;
102103
}
103104
},
104-
clearIcon: function () {
105-
this.inputClearValue = "";
105+
clearIcon: function() {
106+
this.inputClearValue = '';
106107
this.showClearIcon = false;
107108
},
108-
changePassword: function () {
109+
changePassword: function() {
109110
this.showPassword = !this.showPassword;
110111
}
111112
}
112113
}
113114
</script>
114115

115116
<style>
116-
.title{padding:10upx 25upx;}
117-
</style>
117+
.title {
118+
padding: 10upx 25upx;
119+
}
120+
</style>

0 commit comments

Comments
 (0)