加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

Laravel 5 AngularJS html5Mode

发布时间:2020-12-17 10:20:47 所属栏目:安全 来源:网络整理
导读:我正在使用Laravel 5和AngularJS开发一个项目.我想启用 $locationProvider.html5Mode(true); 并停止重新加载页面.当我将其设置为false并访问链接时,页面不会重新加载. 这是我的route.php Route::get('/',function () { return View::make('index'); }); 角度
我正在使用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,页面刷新,我收到此错误:

Sorry,the page you are looking for could not be found.

我改变了我的route.php
Route::get('/',function () { 
    return View::make('index'); 
});


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

并添加了一个基数< base href =“/”>到我的index.php现在一切正常,页面不刷新.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读