<template>
<view class='search'>
<slot name='left'>
<view>返回</view>
</slot>
<input type="text" :value='value' @input='inputChange'>
<slot name='right'>
<view>搜索</view>
</slot>
</view>
</template>
<script>
export default{
props:{
value:{
type:String
}
},
data () {
return {
key:''
}
},
methods:{
inputChange( e ){
this.key = e.detail.value;
}
},
watch:{
key( newVal ){
this.$emit('input',newVal);
this.$emit('change',newVal);
},
value:{
immediate:true,
handler( newVal ){
this.key = newVal;
}
}
}
}
</script>
<style>
.search{
display: flex;
align-items: center;
justify-content: space-between;
width:100%;
height:66rpx;
}
.search input{
width: 559rpx;
height: 66rpx;
padding:0 10rpx;
background: #ccc;
border-radius: 36rpx;
}
</style>