Skip to content

搜索栏 xSearch ​


预览

介绍 ​

可定制化强

平台兼容 ​

HarmonyH5andriodIOS小程序UTSUNIAPP-X SDKversion
☑☑☑️☑️☑️☑️4.76+1.1.18

文件路径 ​

ts

@/uni_modules/tmx-ui/components/x-search/x-search.uvue

使用 ​

ts

<x-search></x-search>

Props 属性 ​

名称说明类型默认值
round输入框圆角
string"8"
showClear是否显示清除图标
booleantrue
modelValue双向绑定的输入值
string""
placeholder输入框提示语
string""
iconColor搜索图标和清除图标的颜色
string"#bfbfbf"
color搜索条背景
string"#ffffff"
cancelFontColor取消的文本色
string"#000000"
darkColor暗黑模式下的搜索条背景,空值取:sheetDarkColor
string""
inputBgColor输入框的背景
string"#f5f5f5"
fontColor输入框的字体颜色
string"#333333"
border边框style: [width, style, color]
Array(): string[] => [] as string[]
darkBorderColor暗黑模式下边框颜色
string""
placeholderStyle输入框的提示样式
string""
showCancel是否显示右侧取消按钮
booleantrue
disabled禁用输入选择
booleanfalse
autoFocus自动获得焦点
booleanfalse

Events 事件 ​

名称参数说明
cancel-取消时触发
clear-清空时触发
rightClick-点击右侧文本时触发
confirm-输入法确认搜索时触发
input-输入时触发
update:modelValue-等同 v-model

Slots 插槽 ​

名称说明数据
left左插槽-
inputLeft--
inputRight--
cancel--
right--

Ref 方法 ​

名称参数返回值说明

示例文件路径 ​

json

/pages/daohang/search

示例源码 ​

uvue
vue
<template>
	<!-- #ifdef MP-WEIXIN -->
	<page-meta :page-style="`background-color:${xThemeConfigBgColor}`">
		<navigation-bar :background-color="xThemeConfigNavBgColor"
			:front-color="xThemeConfigNavFontColor"></navigation-bar>
	</page-meta>
	<!-- #endif -->

	<x-sheet :round="['0']" :padding="['16','0']" :margin="['0','0','0','16']">
		<x-search v-model="inputval"></x-search>
		<x-text>{{inputval}}</x-text>
	</x-sheet>
	<x-sheet>
		<x-text font-size="18" class=" text-weight-b mb-8">搜索栏 xSearch</x-text>
		<x-text color="#999999">样式可自己完全定义。如果还不满足建议修改源码</x-text>
	</x-sheet>
	<x-sheet>
		<x-text font-size="18" class=" text-weight-b">复杂的布局可通过插槽自定义</x-text>
	</x-sheet>
	<x-sheet :round="['0']" :padding="['16','0']" :margin="['0','0','0','16']">
		<x-search right-text="取消" round="64" :show-clear="false">
			<template v-slot:left>
				<view class="flex flex-row flex-row-center-center">
					<x-text class="mr-5 text-size-m">江西省</x-text>
					<x-icon class="mr-5" color="#bfbfbf" name="arrow-down-s-line" font-size="16"></x-icon>
				</view>
			</template>
			<template v-slot:inputLeft>
				<x-icon style="margin-left:12px;" color="primary" name="qr-scan-2-line" font-size="16"></x-icon>
			</template>
			<template v-slot:inputRight>
				<x-button class="mr-2 mt-2" round="24" size="small" height="34" width="62">搜索</x-button>
			</template>
		</x-search>
	</x-sheet>

</template>

<script setup lang="ts">
	import { ref } from 'vue'
	const inputval = ref("")
</script>

<style lang="scss">

</style>
最近更新