重庆小潘seo博客

当前位置:首页 > 重庆网络营销 > 小潘杂谈 >

小潘杂谈

小程序顶部搜索框怎么实现

时间:2020-09-14 06:30:07 作者:重庆seo小潘 来源:
这篇文章主要为大家详细介绍了小程序实现搜索框功能,具有一定的参考价值,感兴趣的小伙伴们可以参考一下 小程序顶部搜索框怎么实现 实现效果如下: 具体代码: 1、WXML文件!--搜索框 --view>2、WXSS文件.weui-search-bar { position: relative; padding: 8p

这篇文章主要为大家详细介绍了小程序实现搜索框功能,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

小程序顶部搜索框怎么实现

小程序顶部搜索框怎么实现

实现效果如下:

小程序顶部搜索框怎么实现

具体代码:

1、WXML文件<!--搜索框 --><view>2、WXSS文件.weui-search-bar { position: relative; padding: 8px 10px; display: -webkit-box; display: -webkit-flex; display: flex; box-sizing: border-box; background-color: #EFEFF4; border-top: 1rpx solid #D7D6DC; border-bottom: 1rpx solid #D7D6DC;}.weui-icon-search { margin-right: 8px; font-size: inherit;}.weui-icon-search_in-box { position: absolute; left: 10px; top: 7px;}.weui-search-bar__text { display: inline-block; font-size: 14px; vertical-align: middle;}.weui-search-bar__form { position: relative; -webkit-box-flex: 1; -webkit-flex: auto;flex: auto; border-radius: 5px; background: #FFFFFF; border: 1rpx solid #E6E6EA;}.weui-search-bar__box { position: relative; padding-left: 30px; padding-right: 30px; width: 100%; box-sizing: border-box; z-index: 1;}.weui-search-bar__input { height: 28px; line-height: 28px; font-size: 14px;}.weui-icon-clear { position: absolute; top: 0; right: 0; padding: 7px 8px; font-size: 0;}.weui-search-bar__label { position: absolute; top: 0; right: 0; bottom: 0; left: 0; z-index: 2; border-radius: 3px; text-align: center; color: #9B9B9B; background: #FFFFFF; line-height: 28px;}.weui-search-bar__cancel-btn { margin-left: 10px; line-height: 28px; color: #09BB07; white-space: nowrap; font-size: 30rpx;}3、JS文件showInput: function () {this.setData({ inputShowed: true});},hideInput: function () {this.setData({ inputVal: "", inputShowed: false});// getList(this);},clearInput: function () {this.setData({ inputVal: ""});// getList(this);},inputTyping: function (e) {//搜索数据// getList(this, e.detail.value);this.setData({ inputVal: e.detail.value});}PHP中文网,大量免费小程序开发教程,欢迎学习!以上就是小程序顶部搜索框怎么实现的详细内容,更多请关注小潘博客其它相关文章!