search.vue 1.5 KB
<template>
	<view>
		<div class="searchDiv">
			<image src="../../static/list/searchIcon.png" mode="widthFix" :class="{'focusClass':isFocus}"></image>
			<input type="text" v-model="searchVal" placeholder="输入名称" placeholder-class="centers" confirm-type='搜索' @focus="inputFocus" @blur="inputBlur" @input="itemChange">
		</div>
		<!-- <div style="position: relative;">
			<slot></slot>
			<div class="toast" v-show="toastShow">
				<div class="toastContent">
					<div class="arrow"></div>
					<span class="typeBox" v-for="item in typeArr" @tap="itemClick(item.key)">{{item.name}}</span>
				</div>
			</div>
		</div>
		<div class="dialog"  v-if="toastShow" @tap="$emit('update:toastShow', false)"></div> -->
	</view>
</template>

<script>
	export default{
		data() {
			return {
				isFocus:false,
				searchVal:''
			}
		},
		props: {
		},
		watch: {
		},
		methods: {
			itemChange() {
				setTimeout(()=>{
					this.$emit('handleEvent',this.searchVal);
					console.log('aaaa',this.searchVal)
				},300)
			},
			inputFocus(){
				this.isFocus=true
			},
			inputBlur(){
				if(this.searchVal==''){
					this.isFocus=false
				}
			}
		},
	}
</script>

<style>
	.searchDiv{
		padding: 12.68upx 23.55upx;
		background: #f4f4f5;
		position: relative;
	}
	.searchDiv input{
		height: 54.34upx;
		background: #fff;
		padding:0 45.28upx;
	}
	.searchDiv image{
		width: 25.37upx;
		position: absolute;
		top: 25.37upx;
		z-index: 9;
		left: 297.1upx;
	}
	.searchDiv .focusClass{
		left: 32.6upx;
		transition: all .3s;
	}
</style>