handleSearch = () => { console.log('Searching for:', searchTerm); }; return ( <div className="<em>search-box</em> <em>search-box</em> { display: flex; align-items: center; margin-bottom: 20px;}.<em>search-box</em> input { padding : 10px; border: 1px solid #ccc; border-radius: 4px 0 0 4px; width: 200px;}.<em>search-box</em> button { padding useEffect(() => { handleSearch(); }, [searchTerm, handleSearch]); return ( <div className="search-box catch (err) { setError('An error occurred while searching.'); }}, 300);return ( <div className="<em>search-box</em>
handleSearch = () => { console.log('Searching for:', searchTerm); }; return ( <div className="<em>search-box</em> .<em>search-box</em> { display: flex; align-items: center; margin-bottom: 20px; } .<em>search-box</em> input { padding: 10px; border: 1px solid #ccc; border-radius: 4px 0 0 4px; width: 200px; } .<em>search-box</em> err) { setError('An error occurred while searching.'); } }, 300); return ( <div className="search-box () => { const { searchTerm, setSearchTerm, error } = useSearch(); return ( <div className="<em>search-box</em>
id="main">
-- 头部区域 --> <view class="<em>search-box</em>"> <view class="search iconfont icon-sousuo" bindtap="toSearch </view> </view> .videoContainer { background-color: #f8f9fd; height: 200vh; } .videoContainer .<em>search-box</em>
-- 搜索框内部盒子 --> <view class="<em>search-box</em>"> <! ; display: flex; align-items: center; // 上下 0 间距, 左右20间距 padding: 0rpx 20rpx; .search-box -- 搜索框内部盒子 --> <view class="<em>search-box</em>" :style="{'broder-radius': radius + 'rpx'}"> 那么在使用该组件时,我们可以对其传参 -- 自定义组件 --> <view class="<em>search-box</em>"> <my-search v-on:"gotosearch"></my-search> </view (){ uni.navigateTo({ url:'/subpackages/search/search' }) 通过样式实现吸顶效果(重要) .search-box
="logo" href="index.html">
<div class="<em>search-box</em> .top-user .logo {
left: 0;
width: 200px;
height: 100px;
display: block;
position: absolute;
}
.<em>search-box</em> input {
width: 100%;
height: 36px;
padding: 8px;
border: 1px solid #b31e22;
}
.<em>search-box</em> button 20px;
height: 36px;
line-height: 36px;
border: 1px solid #b31e22;
background-color: #b31e22;
}
.<em>search-box</em> .help-block a {
color: #999;
text-decoration: none;
}
.<em>search-box</em> .help-block a:hover {color: #b31e22
>
{ color:#fff; } #shop-input { border:none; outline:none; background:transparent; } .search-box { height:30px; border-radius:20px; top:10px; overflow:hidden; z-index:10; } .search-box
310&h=198&c=7&rs=1&bgcl=ffff14&r=0&o=6&dpr=1.3&pid=AlgoBlockDebug" alt="logo" /> <div class="<em>search-box</em> absolute; top: 30%; left: 50%; transform: translate(-50%, -50%); text-align: center;}.container .<em>search-box</em> { display: flex;}.container img { margin-bottom: 30px;}.container .<em>search-box</em> input { width: 512px background: #fff; color: #222; overflow: hidden; -webkit-tap-highlight-color: transparent;}.container .<em>search-box</em>
cancelButton="none" bgColor="#dfdfdf"></uni-search-bar> 效果: 设置背景方法一(用view包裹,设置样式): <view class="<em>search-box</em> :radius="100" @input="input" cancelButton="none" bgColor="#dfdfdf"></uni-search-bar> </view> .search-box background-color: #ff1e0a; } 设置背景方法二(在官方组件内设置) 在uni_modules找到官方组件包 效果(一样) 添加吸顶效果(保持在页面顶部) .search-box
50% 50%表示圆心的位置) */ clip-path: circle(30px at 50% 50%); /* 设置过渡 */ transition: 0.4s; } .search-box background: none; outline: none; color: #fff; font-size: 22px; text-indent: 8px; } .search-box input::placeholder{ color: rgba(255,255,255,0.7); } .search-box .fa{ width: 50px; height #search_btn:checked ~ .container{ clip-path: circle(100%); } #search_btn:checked ~ .container .search-box ="fa fa-close" aria-hidden="true"> </label>
margin-left: 5px; } } } </style> 2.自定义搜索页面 <template> <view> <view class="<em>search-box</em> return [...this.historyList].reverse() } } } </script> <style lang="scss"> .search-box
窗口高度 */ height: 100vh; /* 渐变背景 */ background: linear-gradient(200deg,#e3eeff,#f3e7e9); } .search-box justify-content: center; align-items: center; cursor: pointer; /* 动画过渡 */ transition: 0.4s; } .search-box :hover .search-txt{ width: 200px; padding: 0 6px; } .search-box:hover .search-btn{ background-color : #fff; } </style> </head> <body>
display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; } .search-box } </style> </head> <body>
display: inline-block; } .nav-links a { line-height: 1.4rem; color: inherit; } .navbar .links .search-box { flex: 0 0 auto; vertical-align: top; } .search-box { display: inline-block; position: relative right: 0; height: 3.6rem; box-sizing: border-box; box-shadow: 0 2px 5px rgb(0 0 0 / 6%); } body .search-box margin-right: 15px; color: #999; text-align: right; font-size: 0.9rem; line-height: 45px; } .search-box
进行搜索 html代码 data-act的作用: public.js据此判断是搜索功能还是其他功能 data-role的作用: search.js 据此判断搜索的类型 <div class="<em>search-box</em>
50%;
transform: translate(-50%, -50%);
text-align: center;
}
.search-container .search-box display: flex;
}
.search-container img {
margin-bottom: 30px;
}
.search-container .search-box box-sizing: content-box;
-webkit-tap-highlight-color: transparent;
}
.search-container .search-box ="search-container">
<div class="<em>search-box</em>
4、使用已有的扩展uni-search-bar组件 网址:uni-app官网 (dcloud.net.cn) <template> <view> <view class="<em>search-box</em> lang="scss"> // 设置搜索框的背景颜色 .uni-searchbar { background-color: #c00000; } // 设置为吸顶效果 .search-box
50%;
transform: translate(-50%, -50%);
text-align: center;
}
.search-container .search-box display: flex;
}
.search-container img {
margin-bottom: 30px;
}
.search-container .search-box box-sizing: content-box;
-webkit-tap-highlight-color: transparent;
}
.search-container .search-box ="search-container">
<div class="<em>search-box</em>