我创建路由五月网页这样无法加载刷新路线PARAMS后指数
angular.module("ui",[]).config(function($routeProvider,$locationProvider,$httpProvider)
{
$routeProvider.when('/home',
{
templateUrl: 'home.html'
})
.when('/login',
{
templateUrl: 'login.html'
})
.when('/sign_in',
{
templateUrl: 'create_account.html'
})
.when('/profil',
{
templateUrl: 'profil.html'
})
.when('/note/:id',
{
templateUrl: 'view_note.html'
})
.when('/editNote/:id',
{
templateUrl: 'edit_note.html'
})
.otherwise({
redirectTo: '/home'
});
$locationProvider.html5Mode(true);
});
和服务器端代码(expressjs)
app.get('/*', function(req, res) {
res.sendFile(__dirname + '/views/index.html')
});
app.get('/note/:id', function(req, res) {
res.sendFile(__dirname + '/views/index.html')
});
app.get('/note/*', function(req, res) {
res.sendFile(__dirname + '/views/index.html')
});
app.get('/:id', function(req, res) {
res.sendFile(__dirname + '/views/index.html')
});
所以我所有的路由配置运行完美但是当我尝试刷新我的页面时,几乎所有的页面都运行正常,除了带有/editNote/:id
路由配置的页面。那么如何解决这个服务器端的路由问题(expressjs)
那么,什么是错误? – digit
您不必为每条路径设置新路线。只留下一个,并将其设置为'*'(快速) –
@Patryk我已经尝试将'/ *'更改为'*',但仍然不起作用 –