首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Laravel 5+ AngularJS html5Mode

Laravel 5+ AngularJS html5Mode
EN

Stack Overflow用户
提问于 2015-06-06 22:16:12
回答 1查看 1.8K关注 0票数 5

我正在使用Laravel 5和AngularJS开发一个项目。我想让

代码语言:javascript
复制
$locationProvider.html5Mode(true);

并阻止页面重新加载。当我将页面设置为false并访问链接时,该页面不会重新加载。

这是我的route.php

代码语言:javascript
复制
Route::get('/', function () { 
    return View::make('index'); 
});

角码

代码语言:javascript
复制
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时,页面会刷新,并得到以下错误:

对不起,找不到您要找的页面。

EN

回答 1

Stack Overflow用户

发布于 2015-06-09 00:08:41

我把我的route.php改为

代码语言:javascript
复制
Route::get('/', function () { 
    return View::make('index'); 
});


Route::get('{all}', function () { 
    return View::make('index'); 
});

并且在我的index.php中添加了一个基本的index.php,现在一切正常,页面不刷新。

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30688090

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档