demo.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <div class="demo full">
  3. <h2>基础用法</h2>
  4. <nut-navbar
  5. @on-click-back="back"
  6. @on-click-title="title"
  7. @on-click-send="send"
  8. title="订单详情"
  9. icon="share-n"
  10. ></nut-navbar>
  11. <nut-navbar
  12. @on-click-back="back"
  13. @on-click-title="title"
  14. @on-click-clear="clear"
  15. title="浏览记录"
  16. desc="清空"
  17. ></nut-navbar>
  18. <nut-navbar
  19. :left-show="false"
  20. @on-click-title="title"
  21. @on-click-icon="icon"
  22. @on-click-clear="edit"
  23. @on-click-send="more"
  24. title="购物车"
  25. titIcon="locationg3"
  26. desc="编辑"
  27. icon="more-x"
  28. ></nut-navbar>
  29. <h2>增加tab及右侧按钮</h2>
  30. <nut-navbar
  31. tab
  32. :tabs="[
  33. {
  34. id: '11',
  35. name: '商品'
  36. },
  37. {
  38. id: '22',
  39. name: '店铺'
  40. }
  41. ]"
  42. @switch-tab="switchTab"
  43. @on-click-back="back"
  44. @on-click-title="title"
  45. @on-click-clear="edit"
  46. @on-click-send="list"
  47. desc="编辑"
  48. icon="horizontal-n"
  49. >
  50. </nut-navbar>
  51. <h2>多tab切换导航</h2>
  52. <nut-navbar
  53. :tabs="tabList"
  54. @switch-tab="switchTab"
  55. @on-click-back="back"
  56. icon="more-x"
  57. @on-click-send="send"
  58. >
  59. <template #icons>
  60. <nut-icon
  61. class="icon"
  62. name="share"
  63. @on-click-slot-send="morelist"
  64. ></nut-icon>
  65. </template>
  66. </nut-navbar>
  67. </div>
  68. </template>
  69. <script lang="ts">
  70. import { reactive } from 'vue';
  71. import { createComponent } from '@/utils/create';
  72. const { createDemo } = createComponent('navbar');
  73. export default createDemo({
  74. setup(props, { emit }) {
  75. const tabList = [
  76. {
  77. id: '11',
  78. name: '商品'
  79. },
  80. {
  81. id: '22',
  82. name: '评价'
  83. },
  84. {
  85. id: '33',
  86. name: '详情'
  87. },
  88. {
  89. id: '44',
  90. name: '推荐'
  91. },
  92. {
  93. id: '55',
  94. name: '商品'
  95. },
  96. {
  97. id: '66',
  98. name: '评价'
  99. },
  100. {
  101. id: '77',
  102. name: '详情'
  103. },
  104. {
  105. id: '88',
  106. name: '推荐'
  107. }
  108. ];
  109. const back = () => {
  110. alert('header头部, 点击返回');
  111. };
  112. const title = () => {
  113. alert('header头部, 点击title');
  114. };
  115. const right = () => {
  116. alert('header头部, 点击右侧按钮');
  117. };
  118. const icon = () => {
  119. alert('icon');
  120. };
  121. const send = () => {
  122. alert('发送');
  123. };
  124. const edit = () => {
  125. alert('编辑');
  126. };
  127. const more = () => {
  128. alert('更多');
  129. };
  130. const clear = () => {
  131. alert('清空');
  132. };
  133. const list = () => {
  134. alert('列表');
  135. };
  136. const morelist = () => {
  137. alert('多个更多');
  138. };
  139. function switchTab(id: number, name: string) {
  140. console.log(id, name);
  141. }
  142. return {
  143. back,
  144. title,
  145. right,
  146. send,
  147. edit,
  148. clear,
  149. more,
  150. list,
  151. icon,
  152. morelist,
  153. switchTab,
  154. ...reactive({
  155. tabList
  156. })
  157. };
  158. }
  159. });
  160. </script>
  161. <style lang="scss" scoped></style>