使用Grunt connect的AngularJS html5Mode咕unt 0.4.5
如果有人偶然發(fā)現(xiàn)此問題,請解決以下問題:
(添加的唯一行是modRewrite行)
livereload: { options: {open: true,middleware: function (connect) { return [modRewrite([’^[^.]*$ /index.html [L]’]),connect.static(’.tmp’),connect().use( ’/bower_components’, connect.static(’./bower_components’)),connect.static(appConfig.app) ];} }},
確保在grunt文件的頂部聲明了以下內(nèi)容:
var modRewrite = require(’connect-modrewrite’);解決方法
我最近切換到grunt 0.4.5,它改變了連接的工作方式。
我以前使用過connect-modrewrite,它工作得很好(/:parameter生成的URL出現(xiàn)了一些問題)。
這是與生成器角度0.8.0的grunt 0.4.1一起使用的舊版本,中間件部分由我修改為使用html5mode。
connect: { options: {port: 9000,hostname: ’*IP HERE*’,livereload: 35729,middleware: function (connect,options) { var optBase = (typeof options.base === ’string’) ? [options.base] : options.base; return [require(’connect-modrewrite’)([’!(..+)$ / [L]’])].concat(optBase.map(function(path){ return connect.static(path); }) );} },livereload: {options: { open: true,base: [’.tmp’,’<%= yeoman.app %>’ ]} },
這是Generator-angular 0.9.0-1中的新版本
connect: { options: {port: 9000,livereload: 35729 },middleware: function (connect) {return [ connect.static(’.tmp’),connect().use(’/bower_components’,connect.static(’./bower_components’) ),connect.static(appConfig.app)]; }} },
如何更改此格式以使用mod-rewrite或任何其他方法來實(shí)現(xiàn)html5mode?
我嘗試使用此處提供的方法:https ://gist.github.com/nnarhinen/7719157我將其組合以創(chuàng)建以下內(nèi)容:
middleware: function (connect) { return [connect.static(modRewrite([’^[^.]*$ /index.html [L]’])),connect.static(’.tmp’),connect().use( ’/bower_components’,connect.static(’./bower_components’)),connect.static(appConfig.app) ];}
這使我可以查看普通視圖,但是modRewrite部分似乎沒有執(zhí)行所需的操作,以便通過url進(jìn)入任何其他視圖。
相關(guān)文章:
1. 在應(yīng)用配置文件 app.php 中找不到’route_check_cache’配置項(xiàng)2. html按鍵開關(guān)如何提交我想需要的值到數(shù)據(jù)庫3. mysql取模分表與分表4. gvim - 誰有vim里CSS的Indent文件, 能縮進(jìn)@media里面的5. HTML 5輸入框只能輸入漢字、字母、數(shù)字、標(biāo)點(diǎn)符號?正則如何寫?6. dockerfile - 我用docker build的時(shí)候出現(xiàn)下邊問題 麻煩幫我看一下7. 跟著課件一模一樣的操作使用tp6,出現(xiàn)了錯(cuò)誤8. PHP類屬性聲明?9. objective-c - ios 怎么實(shí)現(xiàn)微信聯(lián)系列表 最好是swift10. javascript - 請教如何獲取百度貼吧新增的兩個(gè)加密參數(shù)
