在 Laravel 视图中使用 CSS?
问题描述
我刚开始学习 Laravel,可以做控制器和路由的基础知识.
I've just began learning Laravel, and can do the basics of a controller and routing.
我的操作系统是 Mac OS X Lion,它位于 MAMP 服务器上.
My OS is Mac OS X Lion, and it's on a MAMP server.
我的来自 routes.php 的代码:
My code from routes.php:
这行得通,视图显示完美,但是"我想要尝试在视图中包含 CSS,我尝试在目录中添加指向样式表的链接,但页面将其显示为默认值浏览器字体,即使 css 在 HTML 中!
That works, the views display perfectly, ''however'' what I want to try and do is include CSS within the views, I tried adding in a link to a stylesheet within the directory but the page displayed it as the default browser font even though the css was in the HTML!
这是视图文件夹中企业的 index.php:
This is index.php from businesses within the views folder:
我尝试在我的其他视图文件夹(测试)中使用 Blade 模板引擎来显示 CSS,但是尽管 CSS 在测试文件夹中,但仍然没有显示 CSS!
I tried using the Blade template engine in my other views folder (testing) to display CSS but again the CSS did not show despite it being in the testing folder!
我怎样才能克服这个问题,变得更好 - 因为我正在慢慢学习这个框架.
How can I overcome this problem, and get better - as I'm slowly learning this framework.
推荐答案
把你的资产放到公用文件夹中;例如:
Put your assets in the public folder; e.g.:
然后,要使用 Laravel 访问它们,请使用:
And then, to access them using Laravel, use:
或者:
此语法将自动生成正确的路径(例如,`public/js/scrollTo.js').
This syntax will automatically generate the correct path (e.g., `public/js/scrollTo.js').
这篇关于在 Laravel 视图中使用 CSS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!