|
@@ -7,8 +7,7 @@
|
|
type="text"
|
|
type="text"
|
|
confirm-type="search"
|
|
confirm-type="search"
|
|
:placeholder="placeholder"
|
|
:placeholder="placeholder"
|
|
- :value="keyword"
|
|
|
|
- @input="$emit('input', $event.target.value)"
|
|
|
|
|
|
+ v-model="inputValue"
|
|
:focus="true"
|
|
:focus="true"
|
|
/>
|
|
/>
|
|
<text v-if="clearable && inputValue" class="clearable iconfont icon-quxiao" @click="clearValue"></text>
|
|
<text v-if="clearable && inputValue" class="clearable iconfont icon-quxiao" @click="clearValue"></text>
|
|
@@ -29,22 +28,12 @@
|
|
<script>
|
|
<script>
|
|
export default {
|
|
export default {
|
|
name: 'CmSearch',
|
|
name: 'CmSearch',
|
|
- model: {
|
|
|
|
- prop: 'keyword',
|
|
|
|
- },
|
|
|
|
-
|
|
|
|
props: {
|
|
props: {
|
|
// 占位字符
|
|
// 占位字符
|
|
placeholder: {
|
|
placeholder: {
|
|
type: String,
|
|
type: String,
|
|
default: '请输入搜索关键字'
|
|
default: '请输入搜索关键字'
|
|
},
|
|
},
|
|
- // 绑定值
|
|
|
|
- keyword: {
|
|
|
|
- type: [String, Number],
|
|
|
|
- default: ''
|
|
|
|
- },
|
|
|
|
-
|
|
|
|
clearable: {
|
|
clearable: {
|
|
type: Boolean,
|
|
type: Boolean,
|
|
default: true
|
|
default: true
|
|
@@ -65,10 +54,20 @@ export default {
|
|
default: true
|
|
default: true
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
+ watch:{
|
|
|
|
+ inputValue(nVal){
|
|
|
|
+ this.$emit('input', nVal)
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ data(){
|
|
|
|
+ return {
|
|
|
|
+ inputValue: ''
|
|
|
|
+ }
|
|
|
|
+ },
|
|
methods: {
|
|
methods: {
|
|
clearValue() {
|
|
clearValue() {
|
|
this.inputValue = ''
|
|
this.inputValue = ''
|
|
- this.$emit('change', '')
|
|
|
|
|
|
+ this.$emit('input', '')
|
|
},
|
|
},
|
|
handleClick() {
|
|
handleClick() {
|
|
if (!this.disabled) return
|
|
if (!this.disabled) return
|