如何使用片段标识符(哈希链接)创建react选项卡?

时间:2019-05-13 20:59:50

标签: typescript react-router react-tabs

我使用react-tabs(https://reactcommunity.org/react-tabs/)创建4个标签页。现在,我需要为它们创建类似“ https://example.com/page=01#tab1”,“ https://example.com/page=01#tab2”的路由。单击选项卡名称时,它们会打开带有所选选项卡的页面。

我试图用react-router-dom中的几个 Dim OutApp As Object Dim OutMail As Object Dim sh As Worksheet Dim cell As Range Dim FileCell As Range Dim rng As Range With Application .EnableEvents = False .ScreenUpdating = False End With Set sh = Sheets("Sheet1") Set OutApp = CreateObject("Outlook.Application") For Each cell In sh.Columns("A").Cells.SpecialCells(xlCellTypeConstants) 'Enter the path/file names in the C:Z column in each row Set rng = sh.Cells(cell.Row, 2).Range("C2:D2") Set OutMail = OutApp.CreateItem(0) With OutMail .to = cell.Value .Subject = "Friendly Reminder" .Body = "Hi " & cell.Offset(0, 2).Value .CC = cell.Value For Each FileCell In rng.SpecialCells(xlCellTypeConstants) If Trim(FileCell) <> "" Then If Dir(FileCell.Value) <> "" Then .Attachments.Add FileCell.Value End If End If Next FileCell .Display 'Or use .Display End With Set OutMail = Nothing Next cell Set OutApp = Nothing With Application .EnableEvents = True .ScreenUpdating = True End With End Sub <Link to="#tab1>Tab1</Link>替换react-tab,但是选项卡没有切换。

1 个答案:

答案 0 :(得分:0)

好的,我只找到一种解决方案:我使用window.location.hash设置并获取hashlink值。另外,我在选项卡名称中添加了onMouseDown回调以模仿路由器:我在此回调中更改window.location.href。