一、定义my-search组件的UI结构如下:
<view class="my-search-container">
<view class="my-search-box">
<uni-icons type="search" size="17"></uni-icons>
<text class="placeholder">搜索</text>
</view>
</view>
注意:在当前组件中,我们使用view组件模拟input输入框的效果,并不会在页面上渲染真正的input输入框
二、美化自定义my-search组件的样式:
<style lang="scss">
.my-search-container {
height: 50px;
background-color: #c00000;
display: flex;
align-items: center;
padding: 0 10px;
.my-search-box {
width: 100%;
height: 36px;
background-color: #ffffff;
border-radius: 18px;
display: flex;
justify-content: center;//横向居中
align-items: center;//纵向居中
.placeholder {
font-size: 15px;
margin-left: 5px;
}
}
}
</style>