Note that the premise is that the directory is set correctly.
Step 1: Open the document and click Insert → Reference → Index and Table of Contents to open the following dialog box:
Step 2: Tick "√" in the boxes before "Click on the table of contents" and "Use hyperlinks instead of page numbers" (that is, select), and set other options according to personal needs. When the settings are finished, click OK.
At this point, the hyperlink of the directory is set.