Home  >  Article  >  Web Front-end  >  How to implement search bar in uniapp

How to implement search bar in uniapp

coldplay.xixi
coldplay.xixiOriginal
2020-12-09 16:00:4511049browse

Uniapp implements the search bar method: use the method placeholder, the code is [

The operating environment of this tutorial: windows7 system, uni-app2.5.1 version, thinkpad t480 computer.

Recommended (Free): uni-app development tutorial

Uniapp’s method of implementing the search bar:

Effect Picture:

How to implement search bar in uniapp

Full code:

<template>
    <view>
        <view class="content1"></view>
        <view class="search-block">
            <view class="search-ico-wapper">
                <image src="../../static/chongzhi_sousuo/chongzhi-icon-sousuo@3x.png" class="search-ico" mode=""></image>
            </view>
            <input type="text" value="" placeholder="点击输入搜索内容" class="search-text" maxlength="10" focus/>
            <view class="search-ico-wapper1">
                <image src="../../static/chongzhi_sousuo/chongzhi-icon-sys@3x.png" class="search-ico-1" mode=""></image>
            </view>
        </view>
        <view class="shadow">
        </view>
    </view>
</template>
<script>
    export default {
        data() {
            return {
            }
        },
        methods: {
        }
    }
</script>
<style>
.content1{
    height: 150upx;
}
page{
    background-color: #FFFFFF;
}
/* 搜索框 */
.search-ico, .search-ico-1{
    width: 40upx;
    height: 40upx;
}
.search-text{
    font-size: 14px;
    background-color: #FFFFFF;
    height: 60upx;
    width: 480upx;
}
.search-block{
    display: flex;
    flex-direction: row;
    padding-left: 60upx;
    position: relative;
    top: -32upx;
}
.search-ico-wapper{
    background-color: #FFFFFF;
    display: flex;
    flex-direction:column;
    justify-content: center;
    padding: 0upx 0upx 0upx 40upx;
    border-bottom-left-radius:18px;
    border-top-left-radius: 18px;
}
.search-ico-wapper1{
    background-color: #FFFFFF;
    display: flex;
    flex-direction:column;
    justify-content: center;
    padding: 0upx 40upx 0upx 0upx;
    border-bottom-right-radius:18px;
    border-top-right-radius: 18px;
}
.shadow{
    width: 638upx;
    height: 60upx;
    border-radius:18px;
    -moz-box-shadow:0 0 10px #e6e6e6;
    -webkit-box-shadow:0 0 10px #e6e6e6;
    box-shadow:0 0 10px #e6e6e6;
    position: relative;
    top: -90upx;
    left: 60upx;
}
</style>

Related free learning recommendations: Programming video

The above is the detailed content of How to implement search bar in uniapp. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn