首页 > 其他分享 >uni-app 4.10封装聊天列表组件

uni-app 4.10封装聊天列表组件

时间:2022-10-14 16:03:44浏览次数:47  
标签:4.10 vue import app update free time uni data


聊天组件free-media-list.vue,如下代码

<template>
<view hover-class="bg-light">
<div class="flex align-stretch">
<view class=" flex align-center justify-center position-relative" style="width: 145rpx;" @click="onClick" @longpress="long">
<free-avatar :src="item.avatar" size="92"></free-avatar>
<!-- 角标 -->
<free-badge badgeClass="position-absolute" bageStyle="top:15rpx;right:15rpx;" :num="item.noreadnum" v-if="item.noreadnum>0"></free-badge>
</view>
<view class="flex flex-column border-bottom flex-1 py-3 pr-3 border-light-secondary">
<view class="flex align-center justify-between mb-1">
<text class="font-md">{{item.nickname}}</text>
<text class="font-sm text-light-muted">{{item.update_time|formateTime}}</text>
</view>
<text class="font text-ellipsis text-light-muted">{{item.data}}</text>
</view>
</div>
</view>
</template>

<script>
import freeAvatar from './free-avatar.vue';
import $Time from "@/common/free-lib/time.js";
import freeBadge from "./free-badge.vue";

export default{
components:{
freeAvatar,
freeBadge
},
props:{
item:Object,
index:Number,
},
methods:{
long(e){
console.log(e)
},
onClick(){
this.$emit('click');
}
}
}
</script>

<style>
</style>

index.nvue引入

<template>
<view class="">
<free-nav-bar :title="'微信(100)'" :fixed='true'>
<template v-slot="title"></template>
</free-nav-bar>

<!-- 列表 -->
<block v-for="(item,index) in list" :key="index">
<free-media-list :item="item" :index="index"></free-media-list>
</block>
</view>
</template>

<script>
import freeNavBar from '@/components/free-ui/free-nav-bar.vue';
import freeMediaList from '@/components/free-ui/free-media-list.vue';
export default {
components: {
freeNavBar,
freeMediaList
},
data() {
return {
list:[
{
avatar:"/static/images/demo/demo6.jpg",
nickname:"昵称",
update_time:1628069958,
data:"你好啊,哈哈哈",
noreadnum:1
},
{
avatar:"/static/images/demo/demo6.jpg",
nickname:"昵称",
update_time:1628069958,
data:"你好啊,哈哈哈",
noreadnum:12
},
{
avatar:"/static/images/demo/demo6.jpg",
nickname:"昵称",
update_time:1628069958,
data:"你好啊,哈哈哈",
noreadnum:2
},
{
avatar:"/static/images/demo/demo6.jpg",
nickname:"昵称",
update_time:1628069958,
data:"你好啊,哈哈哈",
noreadnum:10
}
]
}
},
filters:{
formateTime(value){
return $Time.gettime(value);
}
},
onl oad() {

},
methods: {

}
}
</script>

<style>

</style>


标签:4.10,vue,import,app,update,free,time,uni,data
From: https://blog.51cto.com/u_15565664/5757134

相关文章

  • uni-app 4.12开发弹出层组件(一)基础架构
    弹框开发<template><viewclass=""><free-nav-bar:title="'微信(100)'":fixed='true'><templatev-slot="title"></template></free-nav-bar><!--......
  • uni-app 4.11封装全局mixin
    封装mixin(free-base.js)import$Timefrom"@/common/free-lib/time.js";exportdefault{filters:{formateTime(value){return$Time.gettime(value);}......
  • uni-app 4.13开发弹出层组件(二)弹出关闭功能
    index.nuve页面<template><viewclass=""><free-nav-bar:title="'微信'":noreadnum="1":fixed='true'@openExtend="openExtend"><templatev-slot="title"......
  • uni-app 5.1~5.3 通讯录列表页开发
    通讯录列表页面email.nvue<template><view><!--导航栏--><free-nav-bartitle="通讯录"></free-nav-bar><!--通讯录列表--><free-list-itemv-for=......
  • uni-app 6发现页搭建
    find.nvue文件<template><viewclass="page"><!--导航栏--><free-nav-bartitle="发现"></free-nav-bar><free-list-itemtitle="朋友圈"showRight>......
  • uni-app 16用户投诉开发
    用户投诉user-report.nvue<template><viewclass="page"><!--导航栏--><free-nav-bartitle="用户投诉"showBack:showRight="true"bgColor="bg-white">......
  • uni-app 8聊天页开发
    主文件chat.nvue<template><view><!--导航栏--><free-nav-bartitle="呵呵呵呵":noreadnum="1"showBack><free-icon-buttonslot="right"><textclass......
  • uni-app 7个人中心页开发
    my.nvue内容如下<template><viewclass="page"><free-nav-barbgColor="bg-white"><free-icon-buttonslot="right"><textclass="iconfontfont-md"></text......
  • uni-app 9.2聊天信息设置页(二)
    主页面chat-set.nvue<template><viewstyle="background-color:#EDEDED;"><!--导航栏--><free-nav-bartitle="聊天信息"showBack:showRight="false"></free......
  • MAPPO学习笔记(2) —— 从MAPPO论文入手
    在有了上一节一些有关PPO算法的概念作为基础后,我们就可以正式开始对于MAPPO这一算法的学习。那么,既然要学习一个算法,就不得不去阅读提出这一算法的论文。那么本篇博客将从......