当在Laravel 4中将变量(get)传递给route-> Controller-> View时,我丢失了引导程序样式 [英] I lose my bootstrap styles when passing variable (get) to route->Controller->View in Laravel 4

查看:59
本文介绍了当在Laravel 4中将变量(get)传递给route-> Controller-> View时,我丢失了引导程序样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Bootstrap模板集成到laravel 4,并且在通过GET方法传递变量时遇到问题.我的最终View渲染没有应用任何样式.

I am integrating a Bootstrap template to laravel 4 and I am having an issue when passing variables through the GET method. My final View renders without any style applied.

假设我有这样的链接:

<a href="{{url('offer')}}">Oferta 2015</a>

被这样的路线困住了

Route::get('offer','HomeController@showOffer');

和类似的控制器

public function showOffer()
{
    $Cursos = Curso::paginate(10);
    return View::make('cursos.offer')->with('cursos',$Cursos);
}

这很好用(要约视图扩展的主视图可以完美呈现).

That works just fine (the master view extended by the offer view renders perfectly).

当我尝试传递这样的变量时,就会发生我的问题>

My issue happens when I try to pass a variable like this>

链接:<a href="{{url('offer/2015')}}">Oferta 2015</a>

路线:Route::get('offer/2015',array('myYear'=>'year','uses'=>'HomeController@showOffer'));

这里发生的是我显示了View,但是根本没有样式.就像您摆脱标题中的"link href ..."一样.

What happens here is that I get the View displayed, but with no styles at all. Just like when you get rid of the "link href ..." in the header.

任何想法都会受到赞赏,谢谢.

Any idea would be highly appreciated, thanks.

推荐答案

当前,您已定义所有包含路径 relative .因此,当URL中的目录级别更改时,找不到样式.您应该使用Laravel提供的帮助程序来生成完整的URL.

Currently you have defined all your include paths relative. So when the directory level in the URL changes the styles don't get found. You should use the helpers Laravel provides to generate a full URL.

asset()

<link href="{{ asset('assets/css/bootstrap.min.css') }}" rel="stylesheet">

甚至是帮助程序来创建完整的link标签以包含

Or even a helper to create the full link tag for including

{{ HTML::style('assets/css/bootstrap.min.css') }}

(还有一个用于javascript文件的文件)

(And there's one for javascript files too)

{{ HTML::script('assets/js/script.js') }}

这篇关于当在Laravel 4中将变量(get)传递给route-> Controller-> View时,我丢失了引导程序样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆