2016-07-27 68 views
0
的描述

雖然我能夠從文件系統服務grunt-ngdocs自動生成index.html,每次我嘗試看看我得到的文檔中描述:無法查看生成的文檔

XMLHttpRequest cannot load file:///C:/<file-path> Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource 

即使docs/partialsdocs/partials/api文件夾都是空的。

這是我grunt-ngdocs配置

ngdocs: { 
     options: { 
      dest: 'docs', 
      html5Mode: false, 
      inlinePartials: true, 
      scripts: [ 
       'bower_components/angular/angular.js', 
       'bower_components/angular-animate/angular-animate.js' 
      ] 
     }, 
     api: { 
      src: ['app/scripts/**/*.js'], 
      title: 'Docs' 
     } 
    } 

我在做什麼錯?

謝謝你提前

回答

-1

問題是你必須從服務器運行它。我使用節點http服務器(https://www.npmjs.com/package/http-server)。安裝完畢後,進入docs /目錄並鍵入'http-server'。您將獲得以下信息:

啓動了HTTP服務器,在服務./:http://0.0.0.0:8080

現在,您可以查看在給定的URL(http://0.0.0.0:8080

編輯文檔:

如果您不想從服務器加載它,可以在gruntfile中將選項inlinePartials設置爲true。這是我有:

ngdocs: { 
    options: { 
     dest: 'docs', 
     title: "Docs", 
     inlinePartials: true 
    }, 
    api: { 
     src: ['<%= yeoman.app %>/scripts/**/*.js'], 
     title: 'API Documentation' 
    } 
}, 

見(https://github.com/m7r/grunt-ngdocs

+0

謝謝您的回答,但事實是我試圖避免解決方案,因爲貢獻者之一說[NG-文檔可以送達通過文件系統](https://github.com/m7r/grunt-ngdocs/issues/148#issuecomment-110430549);此外,我發現在一個問題有點與我有關['grunt serve:dist'](http://stackoverflow.com/a/21285745/4277702):你能告訴我是否有可能使用ngdocs使用那個Grunt任務? – Gargaroz

+0

我檢查過是否有其他方法,ngdocs確實允許您將所有模板內聯。這將避免XMLHttpRequest錯誤。檢查編輯的答案。 – andreboekhorst

+0

我的問題是我**在我的Gruntfile中有'inlinePartials:true',但我仍然收到XMLHttpRequest錯誤 – Gargaroz