首页 > 分享 > 微信小程序宠物论坛5

微信小程序宠物论坛5

微信小程序宠物论坛5

最新推荐文章于 2024-02-01 22:58:09 发布

你在干嘛111 于 2020-06-10 20:51:55 发布

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

微信小程序宠物论坛5

搜索模块

对帖子的标题进行模糊查询
界面如图
在这里插入图片描述

JS部分

// 初始化数据化 const db = wx.cloud.database({}); const cont = db.collection('post'); Page({ data:{ post:[], title:'', }, formSubmit: function (e) { this.setData({ title1: e.detail.value.find }) }, // 查询按钮 find(e) { const title1 = this.data.title1 console.log(title1) db.collection("post").where({//collectionName 表示欲模糊查询数据所在collection的名 title: db.RegExp({ regexp: title1, options: 'i' }) }).get({ success: res=>{ console.log(res.data) this.setData({ post: res.data }) const post = this.data.post console.log(post.length) if (post.length == "0") { wx.showModal({ title: '查询结果', content: '无相关结果', success(res) { if (res.confirm) { console.log('用户点击确定') } else if (res.cancel) { console.log('用户点击取消') } } }) } else { } }, }) }, })

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556

WXML部分

<view class="content"> <form bindsubmit="formSubmit"> <view class="search"> <input class="input" type="text" name="find" placeholder="帖子名称" form-type="submit"/> <button class='find' form-type="submit" size="mini" bindtap="find">搜索</button> </view> </form> </view> <view class="main" wx:for="{{post}}" wx:key="post"> <!-- 帖子ID显示 --> <navigator url="../detail/detail?id={{item._id}}" open-type="navigate" > <!-- 标题显示 --> <view class="title">{{item.title}}</view> <view class="pic"> <!-- 显示第一张图片 --> <image style="width:30%;height:69px;" src="{{item.images[0]}}"/> <!-- 头像,发帖人昵称,时间 --> <view class="userinfo" style="flex-direction:row"> <image class="userinfo-avatar" src="{{item.heads}}" background-size="cover"></image> <text decode="{{true}}" class="userinfo-nickname">&nbsp;&nbsp;{{item.nickname}}</text> <text decode="{{true}}" class="userinfo-time">&nbsp;&nbsp;&nbsp;&nbsp;{{item.time}}</text> </view> </view> <view class="line"></view> </navigator> </view>

1234567891011121314151617181920212223242526272829

WXSS部分

.content{ padding-left: 4%; padding-right: 4%; background-color:rgb(0, 255, 200); } .input{ position:relative; top:25rpx; height:25px; margin-right: 200rpx; border:1px solid #130505; } .find{ margin: 10rpx 10rpx 10rpx 10rpx; z-index: 2; border:1px solid #130505; position:relative; left:500rpx; bottom:60rpx } .title{ font-weight: bold; } .desc{ font-size:70%; } .userinfo-avatar { width: 30rpx; height: 30rpx; border-radius: 50%; } .userinfo-nickname { font-weight:bold; font-size:75%; color: black; margin-bottom:30px; } .userinfo-time{ font-size:65%; padding-bottom:40px } .line { border: 1px solid #ccc; opacity: 0.2; } .main{ padding-left: 4%; padding-right: 4% }

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455

相关知识

微信小程序 宠物论坛1[通俗易懂]
微信小程序宠物论坛3
微信小程序宠物论坛6
微信小程序宠物论坛2
计算机毕业设计:基于微信小程序的宠物服务交流系统(思路)
宠物寄养微信小程序
宠托师微信小程序
基于微信小程序的流浪宠物救助宠物领养系统的设计与开发
基于微信小程序的宠物寄养小程序,附源码
基于微信小程序同城宠物服务平台的设计与实现

网址: 微信小程序宠物论坛5 https://m.mcbbbk.com/newsview639494.html

所属分类:萌宠日常
上一篇: 小叶紫檀真假图片对比(小叶紫檀真
下一篇: 小鳄龟怎么区分公母