0

我正在尝试通过在 Angular 中使用 docsify 创建一个文档应用程序。据我所知,需要将 docsify 脚本放在 index.html 文件中。当我将所需的 URL 硬编码为 docsify 主页时,它会完美呈现。但是我需要将 fileURL 从另一个服务或组件传递到 index.html 中的 docsify 脚本中,关于如何实现这一点的任何想法???

索引.html:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>ANGULAR</title>
  <base href="/">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
  <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify/themes/vue.css">
</head>
<body>  
  <app-root>
    <div id="app"></div>
    <script>
      window.$docsify = {
        homepage: 'http://localhost:8080/',
        el: '#app',
        repo: '',
        loadNavbar: 'true',
      }
    </script>
    <script src="//cdn.jsdelivr.net/npm/docsify@4"></script>
  </app-root>
</body>
</html>

服务:

getFile(fileName: string): Observable<data[]> {
    fileUrl = `${this.repoUrl}${fileName}`;
    return this.http.get<data[]>(fileUrl$);
  }
4

0 回答 0