demo.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <template>
  2. <div class="demo">
  3. <nut-fixednav
  4. active-text="基础用法"
  5. :position="{ top: '70px' }"
  6. v-model:visible="visible"
  7. :nav-list="navList"
  8. @selected="selected"
  9. />
  10. <nut-fixednav
  11. type="left"
  12. :position="{ top: '140px' }"
  13. v-model:visible="visible1"
  14. active-text="左侧收起"
  15. un-active-text="左侧展开"
  16. :nav-list="navList"
  17. @selected="selected"
  18. />
  19. <nut-fixednav
  20. :position="{ top: '210px' }"
  21. :overlay="false"
  22. v-model:visible="visible2"
  23. :nav-list="navList"
  24. @selected="selected"
  25. />
  26. <nut-fixednav :position="{ top: '280px' }" type="left" v-model:visible="myActive" @selected="selected">
  27. <template v-slot:list>
  28. <ul class="nut-fixednav__list">
  29. <li class="nut-fixednav__list-item">1</li>
  30. <li class="nut-fixednav__list-item">2</li>
  31. <li class="nut-fixednav__list-item">3</li>
  32. <li class="nut-fixednav__list-item">4</li>
  33. <li class="nut-fixednav__list-item">5</li>
  34. </ul>
  35. </template>
  36. <template v-slot:btn>
  37. <nut-icon name="retweet" color="#fff"> </nut-icon>
  38. <span class="text">{{ myActive ? '自定义开' : '自定义关' }}</span>
  39. </template>
  40. </nut-fixednav>
  41. <!-- 配合 Drag 支持拖拽 ,小程序暂不支持 -->
  42. <nut-drag direction="y" :style="{ right: '0px', bottom: '240px' }">
  43. <nut-fixednav un-active-text="支持拖拽" v-model:visible="visible3" :nav-list="navList" @selected="selected" />
  44. </nut-drag>
  45. </div>
  46. </template>
  47. <script lang="ts">
  48. import { onMounted, reactive, ref } from 'vue';
  49. import { createComponent } from '../../utils/create';
  50. const { createDemo } = createComponent('fixednav');
  51. export default createDemo({
  52. props: {},
  53. setup() {
  54. const visible = ref(false);
  55. const visible1 = ref(false);
  56. const visible2 = ref(false);
  57. const visible3 = ref(false);
  58. const myActive = ref(false);
  59. onMounted(() => {
  60. setTimeout(() => {
  61. visible2.value = true;
  62. }, 1000);
  63. });
  64. const navList = reactive([
  65. {
  66. id: 1,
  67. text: '首页',
  68. icon: 'https://img11.360buyimg.com/imagetools/jfs/t1/117646/2/11112/1297/5ef83e95E81d77f05/daf8e3b1c81e3c98.png'
  69. },
  70. {
  71. id: 2,
  72. text: '分类',
  73. icon: 'https://img12.360buyimg.com/imagetools/jfs/t1/119490/8/9568/1798/5ef83e95E968c69a6/dd029326f7d5042e.png'
  74. },
  75. {
  76. id: 3,
  77. text: '购物车',
  78. num: 2,
  79. icon: 'https://img14.360buyimg.com/imagetools/jfs/t1/130725/4/3157/1704/5ef83e95Eb976644f/b36c6cfc1cc1a99d.png'
  80. },
  81. {
  82. id: 4,
  83. text: '我的',
  84. icon: 'https://img12.360buyimg.com/imagetools/jfs/t1/147573/29/1603/1721/5ef83e94E1393a678/5ddf1695ec989373.png'
  85. }
  86. ]);
  87. const selected = (res: any) => {
  88. console.log(res);
  89. };
  90. return {
  91. visible,
  92. visible1,
  93. visible2,
  94. visible3,
  95. myActive,
  96. navList,
  97. selected
  98. };
  99. }
  100. });
  101. </script>