Page.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <div>
  3. <h2 @click="click">
  4. 页面{{ pageId }}
  5. </h2>
  6. <p>你在 <strong class="text-strong">{{ pageTime }}</strong> 秒前打开本页面</p>
  7. <h3>页签操作</h3>
  8. <p>
  9. <a
  10. class="demo-btn"
  11. @click="$routerTab.refresh()"
  12. >刷新当前页面</a>
  13. <a
  14. class="demo-btn"
  15. @click="$routerTab.close()"
  16. >关闭当前页面</a>
  17. </p>
  18. <p>
  19. <router-link
  20. class="demo-btn"
  21. :to="'../page/'+ nextId"
  22. >
  23. 打开“页面{{ nextId }}”
  24. </router-link>
  25. </p>
  26. <p v-if="prevId > 0">
  27. <router-link
  28. class="demo-btn"
  29. :to="'../page/'+ prevId"
  30. >
  31. 打开“页面{{ prevId }}”
  32. </router-link>
  33. <router-link
  34. class="demo-btn"
  35. :to="'../page/'+ prevId"
  36. @click.native="$routerTab.refresh('../page/'+ prevId)"
  37. >
  38. 全新打开“页面{{ prevId }}”
  39. </router-link>
  40. </p>
  41. <p>
  42. <a
  43. class="demo-btn"
  44. @click="$router.push('../tab-dynamic')"
  45. >打开“动态更新页签”</a>
  46. <a
  47. class="demo-btn"
  48. @click="$routerTab.close('../tab-dynamic')"
  49. >关闭“动态更新页签”</a>
  50. </p>
  51. <h3>iframe 页签操作</h3>
  52. <p>
  53. <a
  54. class="demo-btn"
  55. @click="$routerTab.openIframeTab('https://www.baidu.com', '百度', 'rt-icon-web')"
  56. >打开“百度”</a>
  57. <a
  58. class="demo-btn"
  59. @click="$routerTab.refreshIframeTab('https://www.baidu.com')"
  60. >刷新“百度”</a>
  61. <a
  62. class="demo-btn"
  63. @click="$routerTab.closeIframeTab('https://www.baidu.com')"
  64. >关闭“百度”</a>
  65. </p>
  66. <h3>打开 iframe 页签</h3>
  67. <div class="custom-iframe">
  68. <label>
  69. 名称:
  70. <input
  71. v-model="iframe.title"
  72. name="title"
  73. placeholder="页签标题"
  74. >
  75. </label>
  76. <label>
  77. 网址:
  78. <input
  79. v-model="iframe.src"
  80. name="src"
  81. placeholder="请输入完整的网址"
  82. >
  83. </label>
  84. <a
  85. class="demo-btn primary"
  86. @click="iframe.src && $routerTab.openIframeTab(iframe.src, iframe.title, 'rt-icon-web')"
  87. >打开页签</a>
  88. </div>
  89. <h3>路由信息</h3>
  90. <page-route-info />
  91. </div>
  92. </template>
  93. <script>
  94. import pageTimer from '../mixins/pageTimer'
  95. import PageRouteInfo from '../components/PageRouteInfo'
  96. export default {
  97. name: 'Page',
  98. components: { PageRouteInfo },
  99. mixins: [ pageTimer ],
  100. data () {
  101. let id = this.$route.params.id
  102. let isI18nPage = this.$route.fullPath.indexOf('/i18n/') > -1
  103. return {
  104. pageId: id,
  105. nextId: +id + 1,
  106. prevId: +id - 1,
  107. routeTab: {
  108. title: isI18nPage
  109. ? ['page', id]
  110. : '页面' + id
  111. },
  112. iframe: {
  113. src: 'https://www.hao123.com/',
  114. title: 'Hao123'
  115. }
  116. }
  117. },
  118. methods: {
  119. click () {
  120. console.log(`页面${this.pageId}`)
  121. }
  122. }
  123. }
  124. </script>
  125. <style lang="scss" scoped>
  126. .custom-iframe {
  127. label {
  128. display: block;
  129. margin-bottom: .8em;
  130. }
  131. input {
  132. padding: .4em .8em;
  133. }
  134. }
  135. </style>