我正在使用Laravel 5和AngularJS开发一个项目。我想让
$locationProvider.html5Mode(true);并阻止页面重新加载。当我将页面设置为false并访问链接时,该页面不会重新加载。
这是我的route.php
Route::get('/', function () {
return View::make('index');
});角码
app.config(function($routeProvider, $locationProvider) {
$routeProvider.when('/', {
templateUrl: 'views/feed.html',
controller: 'fdController'
}).when('/collections', {
templateUrl : 'views/collections.html',
controller: 'clController'
}).otherwise({
redirectTo : '/'
});
$locationProvider.html5Mode(true);
});当我访问链接html5Mode(false) localhost:8000/#/ -> localhost:8000/#/feed时,页面不会刷新
当html5Mode(true)和我访问localhost:8000/ -> localhost:8000/feed时,页面会刷新,并得到以下错误:
对不起,找不到您要找的页面。
发布于 2015-06-09 00:08:41
我把我的route.php改为
Route::get('/', function () {
return View::make('index');
});
Route::get('{all}', function () {
return View::make('index');
});并且在我的index.php中添加了一个基本的index.php,现在一切正常,页面不刷新。
https://stackoverflow.com/questions/30688090
复制相似问题