tantan.vue 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template>
  2. <view >
  3. <tantan :list="list" @onChange="change" @onClickImage="clickImage"></tantan>
  4. </view>
  5. </template>
  6. <script>
  7. import tantan from '@/components/dgex-tantan/dgex-tantan.vue'
  8. export default {
  9. components: {
  10. tantan
  11. },
  12. data() {
  13. return {
  14. list: []
  15. }
  16. },
  17. mounted() {
  18. const arr = []
  19. /* 测试数据*/
  20. const tu = [
  21. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2Fc7a27a1ej00qvpu700019c000hs00vlc.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
  22. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2F9f81e6aaj00qvpu70001xc000hs00vmc.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
  23. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2F55bf2cb3j00qvpu70002cc000hs012jc.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
  24. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2F2017725bj00qvpu70001jc000hs00zxc.jpg&thumbnail=660x2147483647&quality=80&type=jpg'
  25. ]
  26. for (let index = 0; index < 10; index++) {
  27. const n = Math.floor(Math.random() * (tu.length - 1))
  28. let data = {
  29. image: tu[n],
  30. title: '你好',
  31. desc: n + 500 + 'm ' + '30分钟前活跃',
  32. tags: ['射手座']
  33. }
  34. arr.push(data)
  35. }
  36. this.list = arr
  37. },
  38. methods: {
  39. change(data) {
  40. // 判断倒数
  41. if (data.currentIndex > this.list.length - 5) {
  42. // 模拟一下最加数据
  43. const tu = [
  44. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2Fc7a27a1ej00qvpu700019c000hs00vlc.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
  45. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2F9f81e6aaj00qvpu70001xc000hs00vmc.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
  46. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2F55bf2cb3j00qvpu70002cc000hs012jc.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
  47. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2F2017725bj00qvpu70001jc000hs00zxc.jpg&thumbnail=660x2147483647&quality=80&type=jpg'
  48. ]
  49. for (let index = 0; index < 10; index++) {
  50. const n = Math.floor(Math.random() * (tu.length - 1))
  51. let newdata = {
  52. image: tu[n],
  53. title: '你好',
  54. desc: n + 500 + 'm ' + '30分钟前活跃',
  55. tags: ['射手座']
  56. }
  57. this.list.push(newdata)
  58. }
  59. }
  60. // console.log(data);
  61. },
  62. clickImage(data) {
  63. console.log(data);
  64. }
  65. }
  66. }
  67. </script>