版权声明:本文为博主原创文章,未经博主允许不得转载。 https://cloud.tencent.com/developer/article/1433514
1.wxml页面代码:
<view class="section\_\_title">
<!-- 搜索框 -->
<input class="center-input input-search" type="text" placeholder="搜索商品" placeholder-class="placeholder-class" bindfocus="intoSearchFunc"/>
</view>
2.wxss页面代码:
.center-input{width: 100%;height: 30px;font: 16px/1 "microsoft yahei";color:#333}
/* input::-ms-input-placeholder{text-align: center;}
input::-webkit-input-placeholder{text-align: center;} */
.placeholder-class{text-align: center;}
input{border:1px solid white;background-color:transparent;text-align: center;}
.left-overflow{overflow-x: hidden;overflow-y: hidden;}
.input-search{
background-image: url(http://211.159.165.227/my/search.png);/*设置小图标*/
background-size: 25px 25px;/*小图标的大小*/
background-position: 65% 4px;/*小图标在input的位置*/
background-repeat: no-repeat;/*背景小图标不重复*/
}
3.js页面代码:
intoSearchFunc: function (e) {
wx.navigateTo({
url: '../search/search'
})
},
js部分代码可以参考微信官方文档:https://developers.weixin.qq.com/miniprogram/dev/api/ui-navigate.html#wxredirecttoobject
4.运行截图: