demo.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <template>
  2. <div class="demo">
  3. <h2>评论图片单行展示</h2>
  4. <nut-cell>
  5. <nut-comment
  6. :images="cmt.images"
  7. :videos="cmt.videos"
  8. :info="cmt.info"
  9. :labels="labels"
  10. @click="handleclick"
  11. @clickImages="clickImages"
  12. :operation="['replay']"
  13. >
  14. <template #comment-labels>
  15. <img
  16. class="nut-comment-header__labels--item"
  17. src="https://img11.360buyimg.com/imagetools/jfs/t1/211858/17/4258/12101/618e6f78Ed0edcadc/e83a673555edf59f.jpg"
  18. />
  19. </template>
  20. </nut-comment>
  21. </nut-cell>
  22. <h2>评论图片多行展示</h2>
  23. <nut-cell>
  24. <nut-comment
  25. headerType="complex"
  26. imagesRows="multi"
  27. :images="cmt.images"
  28. :videos="cmt.videos"
  29. :info="cmt.info"
  30. ellipsis="6"
  31. @clickImages="clickImages"
  32. >
  33. <template #comment-labels>
  34. <img
  35. class="nut-comment-header__labels--item"
  36. src="https://storage.360buyimg.com/imgtools/78925d9440-f9e874d0-e93d-11eb-8e5c-0da9e18a13b1.png"
  37. style="height: 12px"
  38. />
  39. </template>
  40. <template #comment-shop-reply>
  41. <div class="nut-comment-shop">
  42. <span>京东美妆国际:</span
  43. >尊敬的客户您好,非常抱歉给您带来不愉快的购物体验,关于过敏,什么成分都不存在个别性和普遍性。
  44. </div>
  45. </template>
  46. </nut-comment>
  47. </nut-cell>
  48. <h2>追评展示</h2>
  49. <nut-cell>
  50. <nut-comment
  51. imagesRows="multi"
  52. :images="cmt.images"
  53. :videos="cmt.videos"
  54. :info="cmt.info"
  55. :follow="cmt.follow"
  56. @clickImages="clickImages"
  57. ></nut-comment>
  58. </nut-cell>
  59. </div>
  60. </template>
  61. <script lang="ts">
  62. import { onMounted, ref } from '@vue/runtime-core';
  63. import { createComponent } from '@/packages/utils/create';
  64. const { createDemo } = createComponent('comment');
  65. export default createDemo({
  66. props: {},
  67. setup() {
  68. let cmt = ref({});
  69. const labels = () => {
  70. return '<nut-icon name="dongdong" color="#fa2c19"></nut-icon>';
  71. };
  72. const handleclick = (info: any) => {
  73. console.log('进行跳转', info);
  74. };
  75. onMounted(() => {
  76. getData();
  77. });
  78. const getData = () => {
  79. fetch('//storage.360buyimg.com/nutui/3x/comment_data.json')
  80. .then((response) => response.json())
  81. .then((res) => {
  82. cmt.value = res.Comment;
  83. }) //执行结果是 resolve就调用then方法
  84. .catch((err) => console.log('Oh, error', err)); //执行结果是 reject就调用catch方法
  85. };
  86. const clickImages = (imgs: any) => {
  87. console.log('进行图片展示', imgs);
  88. };
  89. return {
  90. cmt,
  91. labels,
  92. handleclick,
  93. clickImages
  94. };
  95. }
  96. });
  97. </script>
  98. <style lang="scss" scoped>
  99. .demo {
  100. }
  101. </style>