通过监听数组变化发现,做一个简单的小论坛还是比较容易的,做起来很轻松,代码附上
<template><div class="exo"><van-nav-bar left-text="返回" @click-left="returnn" title="最近的传染病好多" ></van-nav-bar><div></div><van-cell-group><van-cell value="前几年盛行的埃博拉,还没有解决,现在有冒出来一个新冠肺炎,而且还变异的速度这么快,两剂疫苗都打完了,还有这么多感染,居然国外还有更厉害的变异病毒,真是太恐怖了" /><van-imagewidth="100%"height="200px":src="imgurl"/><van-cell title="江上清风" value="2021-07-28 10:03" /></van-cell-group><div><van-fieldv-model="message"rows="1"autosizelabel="留言"type="textarea"placeholder="请输入留言"><template #button><van-button size="small" type="primary"@click="ppp">发送</van-button></template></van-field></div><div v-for="(item,index) in item" :key="index"><van-cell :value="item.txt"/><van-cell :title="item.name" :value="item.time"/></div><div style="height:80px;"></div></div></template><script>import dayjs from 'dayjs'import img from '../../../public/images/论坛截图1.png'export default {data(){return{imgurl:img,message:"",ooo:{name:'',tex:'',time:''},item:[{name:'泥奏凯',txt:'是啊,天天出行不便,这个不敢,那个不敢,实在是太困扰了',time:'2021-07-28 10:08'},{name:'可乐侠',txt:'同上,我这小区又封上了',time:'2021-07-28 10:23'},{name:'星星之火',txt:'朋友们注意安全,大家加油!',time:'2021-07-28 11:01'},]}},computed:{},methods:{ppp(){this.ooo.name='游客2507'this.ooo.time=dayjs().format('YYYY-MM-DD HH:mm:ss')this.ooo.txt=this.messagethis.item.push(this.ooo)},returnn(){this.$router.push('/consult/index')}}}</script><style lang="scss" scoped>.exo {width: 100%;min-height: 800px;}.van-cell__title{text-align: left !important;}.van-cell__value{text-align: left !important;margin-left: 20px !important;}.van-cell__title{color: #6E8B3D;}</style>

