👉基本示例跟数1,2,3一样简单



<tm-search  ></tm-search>

1
2
3
<script>
	export default {
		data() {
			return {
			}
		}
	}
</script>





 




1
2
3
4
5
6
7
8
9

👉自定义插槽


<tm-search v-model="value"  bgColor="bg-gradient-blue-accent" color="white" insertColor="blue" :showLeft="true">
	<template #left>
		<tm-pickersCity btn-color="bg-gradient-blue-accent" @confirm="okCity" :default-value="addr">
			<view>
				<text class="text-size-n">{{addr[1]}}</text>
				<tm-icons :size="24" color="white" name="icon-angle-down"></tm-icons>
			</view>
		</tm-pickersCity>
	</template>
</tm-search>



 


 


 



1
2
3
4
5
6
7
8
9
10
11
12

👉完整的示例


<template>
	<tm-fullView>
		<template v-slot:default="{info}">
			<view class="grey text " :class="tmVuetify.black?'black bk':''" :style="{minHeight:info.height+'px'}">
				<tm-menubars title="搜索组件" color="bg-gradient-blue-accent"  :showback="true"></tm-menubars>
				
				<tm-search v-model="value" suffix-icon="icon-plus"  bgColor="bg-gradient-blue-accent" color="white" insertColor="blue" :showLeft="true">
					<template #left>
						<view>
							<tm-pickersCity btn-color="bg-gradient-blue-accent" @confirm="okCity" :default-value="addr">
								<view>
									<text class="text-size-n">{{addr[1]}}</text>
									<tm-icons :size="24" color="white" name="icon-angle-down"></tm-icons>
								</view>
							</tm-pickersCity>
							<view class="text-size-xs">请选择</view>
						</view>
					</template>
					<template #suffixIcon>
						<view class="border-blue-l-1 pl-24  flex-center " style="height: 30rpx;line-height: 30rpx;">
							<tm-icons dense name="icon-qrcode" color="blue"></tm-icons>
						</view>
					</template>
					<template #right>
						
						<view style="width: 42rpx;height:42rpx;" class="rounded border-white-a-1 text-align-center flex-center">
							<tm-icons  :size="22" name="icon-plus" color="white"></tm-icons>
						</view>
					</template>
				</tm-search>

				<tm-search v-model="value" showLeft  prefixIcon="" suffixIcon="icon-search"></tm-search>
				<view style="height: 50upx;"></view>
				<tm-search clear v-model="value" prefixText="地址" confirmText="取消" color="green" insertColor="green" align="center"></tm-search>
				<view style="height: 50upx;"></view>
				<tm-search v-model="value" bgColor="bg-gradient-pink-accent" insertColor="pink"  align="center" :showRight="false" :round="24"></tm-search>
				<view style="height: 50upx;"></view>
				
				
			</view>
		</template>
	</tm-fullView>

</template>

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
<script>
	export default {
		data() {
			return {
				addr:['江西省','南昌市','西湖区'],
				value:''
			}
		},
		methods: {
			okCity(e){
				console.log(e);
				this.addr = e;
			}
		}
	}
</script>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

👉props属性表

属性名称类型可选值默认值说明
valueString-''建议valu.sync或者v-model
left-iconString-'icon-angle-left'左边图标
prefix-textString-''输入框内前缀文字
confirm-textString-'搜索'右边文字
prefix-iconString-'icon-search'输入框内前缀图标
suffix-iconString''输入框内后缀图标
placeholderString'请输入关键词'输入框的点位符
insert-colorString任意主题色名'primary'输入框内图标的主题色
colorString任意主题色名'primary'外部图标文字的主题色
bg-colorString任意主题色名'white'搜索框的背景
alignStringleft/right/center'left'输入框输入对齐的方式
disabledBooleantrue|falsefalse是否禁用
show-leftBooleantrue|falsefalse是否显示左边部分
show-rightBooleantrue|falsefalse是否显示右边
clearBooleantrue|falsefalse是否显示清除图标
blackBooleantrue|falsenull是否暗黑模式
roundNumber任意整数2输入框内圆角rpx
shadowNumber任意整数4搜索框的投影rpx

👉slot插槽

属性名称参数类型参数说明
left--左边插槽
right--右边插槽
suffixIcon1.1.9--输入框内后缀图标插槽

👉事件

事件名称返回参数返参类型说明
@cancel--点击左边图标触发的事件
@clear--点击输入框清除图标时的触发事件。
@confirm当前输入值-输入法键盘上点击确认,输入框后缀图标,右边部分点击时产生的事件,含当前输入的内容
@click--点击组件产生的事件

👉更新日志

2021年9月12日 初始版本。

tmzdy 于 2022/12/7 编辑 报错? | 评论?