视图中显示的 laravel @if 语句

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/48916444/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 17:25:59  来源:igfitidea点击:

laravel @if statements displayed in view

phplaravelubuntulampp

提问by miles johnson

I'm learning Laravel for the first time, just started today. Fresh Laravel install via Composer on LAMPP - Ubuntu. After I run sudo /opt/lampp lampp startin my terminal, I open Chrome and nav to localhost/MYAPP/resources/views/welcome.blade.php. Thisis the view that is rendered. The "@" statements (that I assume are specific to Laravel's controllers) are rendered to the screen in the browser and I cannot figure out why this is happening.

我是第一次学习 Laravel,今天才开始。在 LAMPP - Ubuntu 上通过 Composer 安装新的 Laravel。sudo /opt/lampp lampp start在我的终端中运行后,我打开 Chrome 并导航到 localhost/MYAPP/resources/views/welcome.blade.php。是呈现的视图。“@”语句(我假设特定于 Laravel 的控制器)被渲染到浏览器的屏幕上,我无法弄清楚为什么会发生这种情况。

Any/all insight is appreciated!

任何/所有见解都表示赞赏!

EDIT: As requested here is my welcome.blade.php file:

编辑:按照这里的要求是我的welcome.blade.php 文件:

<!doctype html>
<html lang="{{ app()->getLocale() }}">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Laravel</title>

    <!-- Fonts -->
    <link href="https://fonts.googleapis.com/css?family=Raleway:100,600" rel="stylesheet" type="text/css">

    <!-- Styles -->
    <style>
        html, body {
            background-color: #fff;
            color: #636b6f;
            font-family: 'Raleway', sans-serif;
            font-weight: 100;
            height: 100vh;
            margin: 0;
        }

        .full-height {
            height: 100vh;
        }

        .flex-center {
            align-items: center;
            display: flex;
            justify-content: center;
        }

        .position-ref {
            position: relative;
        }

        .top-right {
            position: absolute;
            right: 10px;
            top: 18px;
        }

        .content {
            text-align: center;
        }

        .title {
            font-size: 84px;
        }

        .links > a {
            color: #636b6f;
            padding: 0 25px;
            font-size: 12px;
            font-weight: 600;
            letter-spacing: .1rem;
            text-decoration: none;
            text-transform: uppercase;
        }

        .m-b-md {
            margin-bottom: 30px;
        }
    </style>
</head>
<body>
    <div class="flex-center position-ref full-height">
        @if (Route::has('login'))
            <div class="top-right links">
                @auth
                    <a href="{{ url('/home') }}">Home</a>
                @else
                    <a href="{{ route('login') }}">Login</a>
                    <a href="{{ route('register') }}">Register</a>
                @endauth
            </div>
        @endif

        <div class="content">
            <div class="title m-b-md">
                Laravel
            </div>

            <div class="links">
                <a href="https://laravel.com/docs">Documentation</a>
                <a href="https://laracasts.com">Laracasts</a>
                <a href="https://laravel-news.com">News</a>
                <a href="https://forge.laravel.com">Forge</a>
                <a href="https://github.com/laravel/laravel">GitHub</a>
            </div>
        </div>
    </div>
</body>

采纳答案by miles johnson

After a week now of double checking my PATH and versions for everything, I've figured out that I simply needed to navigate to the directory where my application is stored and run the command php artisan serve.

经过一周的仔细检查我的 PATH 和所有版本的所有内容后,我发现我只需要导航到存储我的应用程序的目录并运行命令php artisan serve.

Major props to user Yachi ? for his attentive help.

用户 Yachi 的主要道具?因为他的细心帮助。

回答by Adam Kozlowski

The @in laravel blade view is injection of some php commends and shortcuts. For example:

@在laravel叶片视图是一些PHP赞扬和快捷方式的注射。例如:

@if(condition)
    some data
@else
    some data
@endif

Is the same as:

是相同的:

<?php if(condition){ ?>
    some data
<?php } else { ?>
    some data
<?php } ?>

You will find more here: https://laravel.com/docs/5.6/blade

您会在此处找到更多信息:https: //laravel.com/docs/5.6/blade

When it comes to Laravel it is a basic so read it carefully.

说到 Laravel,它是一个基础,所以请仔细阅读。