Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 
 

46 строки
1.8 KiB

  1. <template>
  2. <view>
  3. <l-title>普通聊天记录:</l-title>
  4. <l-chat>
  5. <l-chat-msg avatar="https://img.learun.cn/wxcx/pic.jpg" date="2019-12-12">我是一条对方发来的消息</l-chat-msg>
  6. <l-demo-description>
  7. 聊天记录需要使用 l-chat 标签包裹,聊天记录使用 l-chat-msg 标签,标签内容即为聊天文字 属性 avatar 设置头像;
  8. 属性 date 或同名插槽设置日期时间;属性 type 可以取值 left/right 表示聊天记录是左侧还是右侧,默认在左
  9. </l-demo-description>
  10. <l-chat-msg type="right" date="6月1日" avatar="https://img.learun.cn/wxcx/pic.jpg">
  11. 我是一条自己发出的消息
  12. </l-chat-msg>
  13. <l-chat-msg date="18:00" leftColor="yellow" avatar="https://img.learun.cn/wxcx/pic.jpg">
  14. 我是特殊颜色的消息
  15. </l-chat-msg>
  16. <l-chat-msg date="19:25" roundAvatar avatar="https://img.learun.cn/wxcx/pic.jpg">我的头像是圆的</l-chat-msg>
  17. <l-demo-description>
  18. 属性leftColor/rightColor 设置在左/右侧显示时的聊天记录的背景色;属性 roundAvatar 可以设置为圆形头像
  19. </l-demo-description>
  20. </l-chat>
  21. <l-demo-description>
  22. 使用 l-chat-input 作为输入框,输入框的内容使用 v-model 绑定,属性 placeholder 设置占位符;
  23. 点击发送按钮后,会触发 sendMsg 事件,可以监听该事件以获取输入内容;
  24. 使用输入框时请为页面添加一条样式: page { padding-bottom: 100rpx; }
  25. </l-demo-description>
  26. <l-chat-input v-model="msgInput" placeholder="这里输入消息内容" />
  27. </view>
  28. </template>
  29. <script>
  30. export default {
  31. data() {
  32. return {
  33. msgInput: ''
  34. }
  35. }
  36. }
  37. </script>
  38. <style lang="less">
  39. page {
  40. padding-bottom: 100rpx;
  41. }
  42. </style>