简体   繁体   English

HTML无法在Laravel视图中呈现

[英]HTML not rendering in Laravel Views

I'm new to Laravel and I'm trying to understand the correct way to handle web pages using Laravel. 我是Laravel的新手,我试图了解使用Laravel处理网页的正确方法。

Currently, I have a default route that leads to a file named login.php. 目前,我有一个默认路由,该路由会导致一个名为login.php的文件。 login.php contains nothing but html, but when I go to localhost/myapp/public/index.php/ , login.php's html structure is displayed instead of the file rendering. login.php仅包含html,但是当我转到localhost / myapp / public / index.php /时,将显示login.php的html结构而不是文件呈现。

For example, if I were to say <\\p>Hello World<\\p> ( without the '\\', so a real paragraph tag ) , I would get <\\p>Hello World<\\p> instead of: 例如,如果我说<\\ p> Hello World <\\ p>(没有'\\',则是一个真实的段落标签),我会得到<\\ p> Hello World <\\ p>而不是:

Hello World 你好,世界

My current route is this: 我当前的路线是这样的:

Route::get('/', function(){ 路线:: get('/',function(){

    return View::make('login');

});

And login.php is just a basic html file. 而login.php只是一个基本的html文件。 When the View gets returned, I get the html without the rendering. 当视图返回时,我得到的HTML没有渲染。

This is my .htaccess file: 这是我的.htaccess文件:

Options -MultiViews 选项-MultiViews

RewriteEngine On

# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

Any ideas? 有任何想法吗? Oh, and sorry about the formatting for this question. 哦,很抱歉,此问题的格式。 I'm new to StackOverflow. 我是StackOverflow的新手。 Thanks! 谢谢!

the route file should look like this 路由文件应如下所示

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

assuming that login.php is in app/views/ folder. 假设login.php位于app/views/文件夹中。

and this is the url to access the login page assuming you are using artisan to run the server localhost:8000/login.php 假设您正在使用artisan运行服务器localhost:8000/login.php ,这是访问登录页面的URL。

My problem was that I had to start the Laravel Server in order to actually view my pages. 我的问题是我必须启动Laravel服务器才能实际查看我的页面。

Once I did 一旦我做了

php artisan serve

and went out to the root of my localhost, everything worked properly. 然后走到我本地主机的根目录,一切正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM