comment.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // component/comment.js
  2. Component({
  3. /**
  4. * 组件的属性列表
  5. */
  6. properties: {
  7. commentList: {
  8. type: Array,
  9. value: [],
  10. observer: function observer() {
  11. console.log(123)
  12. this.formatList()
  13. }
  14. }
  15. },
  16. /**
  17. * 组件的初始数据
  18. */
  19. data: {
  20. inputValue: '',
  21. showControl: 0
  22. },
  23. /**
  24. * 组件的方法列表
  25. */
  26. methods: {
  27. formatList: function formatList(changeIndex) {
  28. this.data.commentList.map((item, index) => {
  29. if (changeIndex && index === changeIndex) {
  30. item.showControl = 100;
  31. } else {
  32. item.showControl = 0;
  33. }
  34. })
  35. this.setData({
  36. commentList: this.data.commentList
  37. })
  38. console.log(321, this.data.commentList)
  39. },
  40. showMore: function showMore(e) {
  41. // this.formatList(100)
  42. },
  43. sendReply: function sendReply(e) {
  44. console.log('sendReply', e.detail.value)
  45. this.triggerEvent('sendReply', {
  46. content: e.detail.value
  47. });
  48. this.setData({
  49. inputValue: '',
  50. })
  51. },
  52. }
  53. })