use*_*818 6 html5 mode angularjs laravel-5
我正在使用Laravel 5和AngularJS开发一个项目.我想启用
$locationProvider.html5Mode(true);
Run Code Online (Sandbox Code Playgroud)
并停止重新加载页面.当我将其设置为false并访问链接时,页面不会重新加载.
这是我的 route.php
Route::get('/', function () {
return View::make('index');
});
Run Code Online (Sandbox Code Playgroud)
角度代码
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);
});
Run Code Online (Sandbox Code Playgroud)
当我访问链接时html5Mode(false)
localhost:8000/#/ -> localhost:8000/#/feed
,页面不会刷新
当html5Mode(true)
我访问时
localhost:8000/ -> localhost:8000/feed
,页面刷新,我收到此错误:
抱歉,找不到您要查找的页面.
我改变了我的route.php
Route::get('/', function () {
return View::make('index');
});
Route::get('{all}', function () {
return View::make('index');
});
Run Code Online (Sandbox Code Playgroud)
并<base href="/">
为我的index.php 添加了一个基础现在一切正常,页面不刷新.
归档时间: |
|
查看次数: |
1749 次 |
最近记录: |