我發展的角度應用(1.5.2),並在一種情況下有狀態函數網址如下UI路由器(0.2.18)與點參數
http://localhost:3000/payment/1.1/2/3
但我發現了一個錯誤:
Cannot GET /payment/1.1/2/3
ui-router的版本 - 0.2.18。我讀到他們解決了這個問題,但對我來說這是行不通的。在SO上的相同答案也不能幫助我。
這個國家的配置:
.state('payment', {
url: '/payment/:token/:id/:chanel_id',
templateUrl: 'app/payment/payment.html',
controller: 'PaymentController',
controllerAs: 'vm'
});
我server.js文件:
'use strict';
var path = require('path');
var gulp = require('gulp');
var conf = require('./conf');
var browserSync = require('browser-sync');
var browserSyncSpa = require('browser-sync-spa');
var util = require('util');
var proxyMiddleware = require('http-proxy-middleware');
var historyApiFallback = require('connect-history-api-fallback');
function browserSyncInit(baseDir, browser) {
browser = browser === undefined ? 'default' : browser;
var routes = null;
if(baseDir === conf.paths.src || (util.isArray(baseDir) && baseDir.indexOf(conf.paths.src) !== -1)) {
routes = {
'/bower_components': 'bower_components'
};
}
var server = {
baseDir: baseDir,
routes: routes,
middleware: [ historyApiFallback() ]
};
browserSync.instance = browserSync.init({
startPath: '/',
server: server,
browser: browser
});
}
browserSync.use(browserSyncSpa({
selector: '[ng-app]'// Only needed for angular apps
}));
gulp.task('serve', ['watch'], function() {
browserSyncInit([path.join(conf.paths.tmp, '/serve'), conf.paths.src]);
});
gulp.task('serve:dist', ['build'], function() {
browserSyncInit(conf.paths.dist);
});
gulp.task('serve:e2e', ['inject'], function() {
browserSyncInit([conf.paths.tmp + '/serve', conf.paths.src], []);
});
gulp.task('serve:e2e-dist', ['build'], function() {
browserSyncInit(conf.paths.dist, []);
});
你嘗試使用一些工具,如郵遞員或curl先做純GET /payment/1.1/2/3以查看它是否有效? – Kossel
很奇怪,但是和郵差工作很好 – BordiArt
我也在爲此苦苦掙扎。最終我不得不將值更改爲像'1.1'到'1%2E1'這樣的html編碼。 – Priya