刷新路由参数后无法加载索引

我为这个可能的网页创build路由

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') }); 

所以我所有的路由configuration运行完美,但当我尝试刷新我的页面几乎所有的页面运行正常,除了/editNote/:id路由configuration页面。 所以如何解决这个服务器端路由问题(expressjs)

在这里输入图像描述

在服务器文件上添加:

app.use('/*', function (req, res) { res.sendFile(__dirname + '/views/index.html'); });

删除

 app.get('/note/*', function(req, res) { res.sendFile(__dirname + '/views/index.html') }); 

最后我才能弄清楚真正的问题,就是引起mongoose路线和快速路线之间的同名路线。 所以我改变了angularjs路由名称