index.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. //Component Object
  2. Component({
  3. properties: {
  4. commentsList: {
  5. type: Array,
  6. value: [],
  7. observer: function () {}
  8. },
  9. },
  10. data: {
  11. },
  12. methods: {
  13. // 预览图片
  14. previewImg: function (e) {
  15. //获取当前图片的下标
  16. var index = e.currentTarget.dataset.index;
  17. var active = e.currentTarget.dataset.active;
  18. //所有图片
  19. var imgurls = this.properties.commentsList[active].comments.imgs;
  20. var imgs = []
  21. imgurls.forEach(function (item,i,array) {
  22. imgs.push(item.imgurl);
  23. })
  24. wx.previewImage({
  25. //当前显示图片
  26. current: imgs[index],
  27. //所有图片
  28. urls: imgs
  29. })
  30. },
  31. },
  32. created: function () {
  33. },
  34. attached: function () {
  35. },
  36. ready: function () {
  37. },
  38. moved: function () {
  39. },
  40. detached: function () {
  41. },
  42. });