另一種方法
帆由default.To提供EJS模板覆蓋這一點,並使用.html文件,這裏是一個簡單的解決方案。在您的Sails App中,轉到config/routes.js。您將在那裏看到以下代碼
module.exports.routes = {
/***************************************************************************
* *
* Make the view located at `views/homepage.ejs` (or `views/homepage.jade`, *
* etc. depending on your default view engine) your home page. *
* *
* (Alternatively, remove this and add an `index.html` file in your *
* `assets` directory) *
* *
***************************************************************************/
'/': {
view: 'homepage'
}
/***************************************************************************
* *
* Custom routes here... *
* *
* If a request to a URL doesn't match any of the custom routes above, it *
* is matched against Sails route blueprints. See `config/blueprints.js` *
* for configuration options and examples. *
* *
***************************************************************************/
};
將路由移除到'/',如下所示。保持空白
新routes.js看起來像
module.exports.routes = {
//Remove '/' :)
};
好吧!現在完成了,您可以在Sails應用程序中使用您的HTML文件。將您的index.html放置在資產文件夾中。現在帆從這裏裝載的意見:)
此更改是否提供任何速度改進?或者你想改變這個的原因是什麼? – cfl
沒有速度的改進,只是喜歡用'.html'擴展名來表達我的觀點 –