Skip to content

Commit 9540278

Browse files
committed
feat(docs): the official website adds API anchor function
1 parent 124e50a commit 9540278

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

examples/sites/src/views/components/components.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@
248248

249249
<script lang="jsx">
250250
import { defineComponent, reactive, computed, toRefs, watch, onMounted, ref, onUnmounted, nextTick } from 'vue'
251+
import { useRoute } from 'vue-router'
251252
import { marked } from 'marked'
252253
import hljs from 'highlight.js'
253254
import { Anchor, ButtonGroup, Grid, GridColumn, Tabs, TabItem, Tooltip } from '@opentiny/vue'
@@ -279,6 +280,8 @@ export default defineComponent({
279280
const isRunningTest = localStorage.getItem('tiny-e2e-test') === 'true'
280281
const anchorRefreshKey = ref(0)
281282
const apiTableRef = ref()
283+
const route = useRoute()
284+
282285
const state = reactive({
283286
webDocPath: computed(() => ''),
284287
langKey: getWord('zh-CN', 'en-US'),
@@ -310,7 +313,7 @@ export default defineComponent({
310313
currAnchorLinks: computed(() => (state.activeTab === 'demos' ? state.demoAnchorLinks : state.apiAnchorLinks)),
311314
// 单demo显示时
312315
singleDemo: null,
313-
activeTab: 'demos',
316+
activeTab: route.hash === '#api' ? 'api' : 'demos',
314317
tableData: {},
315318
currApiTypes: [],
316319
showApiTab: computed(() => state.currApiTypes.length),
@@ -616,7 +619,8 @@ export default defineComponent({
616619
copyText: (text) => {
617620
navigator.clipboard.writeText(text)
618621
},
619-
onTabsClick: () => {
622+
onTabsClick: (data) => {
623+
router.push(`#${data.name}`)
620624
scrollToLayoutTop()
621625
},
622626
// 点击 api区域的 name列时

0 commit comments

Comments
 (0)