通过监听数组变化发现,做一个简单的小论坛还是比较容易的,做起来很轻松,代码附上

    1. <template>
    2. <div class="exo">
    3. <van-nav-bar left-text="返回" @click-left="returnn" title="最近的传染病好多" >
    4. </van-nav-bar>
    5. <div></div>
    6. <van-cell-group>
    7. <van-cell value="前几年盛行的埃博拉,还没有解决,现在有冒出来一个新冠肺炎,而且还变异的速度这么快,两剂疫苗都打完了,还有这么多感染,居然国外还有更厉害的变异病毒,真是太恐怖了" />
    8. <van-image
    9. width="100%"
    10. height="200px"
    11. :src="imgurl"
    12. />
    13. <van-cell title="江上清风" value="2021-07-28 10:03" />
    14. </van-cell-group>
    15. <div>
    16. <van-field
    17. v-model="message"
    18. rows="1"
    19. autosize
    20. label="留言"
    21. type="textarea"
    22. placeholder="请输入留言"
    23. ><template #button>
    24. <van-button size="small" type="primary"
    25. @click="ppp">发送</van-button>
    26. </template></van-field></div>
    27. <div v-for="(item,index) in item" :key="index">
    28. <van-cell :value="item.txt"/>
    29. <van-cell :title="item.name" :value="item.time"/>
    30. </div>
    31. <div style="height:80px;"></div>
    32. </div>
    33. </template>
    34. <script>
    35. import dayjs from 'dayjs'
    36. import img from '../../../public/images/论坛截图1.png'
    37. export default {
    38. data(){
    39. return{
    40. imgurl:img,
    41. message:"",
    42. ooo:{
    43. name:'',
    44. tex:'',
    45. time:''
    46. }
    47. ,
    48. item:[
    49. {
    50. name:'泥奏凯',
    51. txt:'是啊,天天出行不便,这个不敢,那个不敢,实在是太困扰了',
    52. time:'2021-07-28 10:08'
    53. },
    54. {
    55. name:'可乐侠',
    56. txt:'同上,我这小区又封上了',
    57. time:'2021-07-28 10:23'
    58. },
    59. {
    60. name:'星星之火',
    61. txt:'朋友们注意安全,大家加油!',
    62. time:'2021-07-28 11:01'
    63. },
    64. ]
    65. }
    66. },
    67. computed:{
    68. },
    69. methods:{
    70. ppp(){
    71. this.ooo.name='游客2507'
    72. this.ooo.time=dayjs().format('YYYY-MM-DD HH:mm:ss')
    73. this.ooo.txt=this.message
    74. this.item.push(this.ooo)
    75. },
    76. returnn(){
    77. this.$router.push('/consult/index')
    78. }
    79. }
    80. }
    81. </script>
    82. <style lang="scss" scoped>
    83. .exo {
    84. width: 100%;
    85. min-height: 800px;
    86. }
    87. .van-cell__title{
    88. text-align: left !important;
    89. }
    90. .van-cell__value{
    91. text-align: left !important;
    92. margin-left: 20px !important;
    93. }
    94. .van-cell__title{
    95. color: #6E8B3D;
    96. }
    97. </style>

    image.png