forked from alibaba/weex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.we
85 lines (73 loc) · 1.62 KB
/
test.we
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
<style>
.cnx-searchbar-item {
width: 750;
height: 80;
font-size: 30;
}
</style>
<template>
<div class="cnx-searchbar">
<div class="search-wrap">
<image
src="https://gw.alicdn.com/tps/TB18o6iLXXXXXXaaXXXXXXXXXXX-31-30.png"
class="search-icon">
</image>
<input
type="text"
value="{{value}}"
class="cnx-searchbar-item"
id="search-input"
placeholder="{{placeholder}}"
oninput="_handleInput"
onchange="_handleChange">
</input>
<image
src="https://gw.alicdn.com/tps/TB1V6TCLXXXXXaUXpXXXXXXXXXX-28-28.png"
class="clear-btn"
onclick="_handleClear"
if="{{bClear}}">
</image>
</div>
<div class="cancel-btn" if="{{bClear}}" onclick="_handleClear">
<text style="font-size:30px;color:#00aaee;">取消</text>
</div>
</div>
</template>
<script>
module.exports = {
data: function(){
return {
placeholder: '搜索',
value: '',
key : ''
}
},
ready : function(){
this.input = this.$el('search-input');
},
methods: {
_handleInput: function(e){
this.value = e.value;
this.$dispatch('cnx-searchbar-input', {
value: e.value,
key : this.key
});
},
_handleChange : function(e){
this.value = e.value;
this.$dispatch('cnx-searchbar-change', {
value : e.value,
key : this.key
})
},
_handleClear: function(e) {
this.value = '';
}
},
computed : {
bClear : function(){
return this.value !== '';
}
}
}
</script>