chatroom.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template>
  2. <cover-view class="div chatroom-scoll">
  3. <cover-view class="div content">
  4. <cover-view v-for="item in message" :key="item.id" class="div line">
  5. <message-item :item="item" id="item.id"></message-item>
  6. <cover-view class="line-content"></cover-view>
  7. </cover-view>
  8. </cover-view>
  9. </cover-view>
  10. </template>
  11. <script>
  12. import messageItem from './message-item'
  13. export default {
  14. props: {
  15. message: {
  16. type: Array,
  17. default: function () {
  18. return []
  19. }
  20. }
  21. },
  22. data () {
  23. return {
  24. viewID: ''
  25. }
  26. },
  27. methods: {
  28. },
  29. watch: {
  30. message: function (nexto, preo) {
  31. if (nexto.length) {
  32. const last = nexto[nexto.length - 1]
  33. this.viewID = last.id
  34. // 限制展示在页面上的消息条数
  35. }
  36. }
  37. },
  38. components: {
  39. messageItem
  40. },
  41. computed: {},
  42. created () {}
  43. }
  44. </script>
  45. <style lang="scss" scoped>
  46. .chatroom-scoll {
  47. /* #ifndef APP-PLUS-NVUE */
  48. max-height: 30vh;
  49. widows: 100%;
  50. /* #endif */
  51. }
  52. .content{
  53. position: absolute;
  54. bottom: 0;
  55. }
  56. .line{
  57. /* #ifndef APP-PLUS-NVUE */
  58. display: flex;
  59. /* #endif */
  60. flex-direction: row;
  61. }
  62. .line-content{
  63. flex:1
  64. }
  65. </style>