layout.blade.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Learning Laravel With Tut.</title>
</head>
<body>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/about">About Us</a></li>
<li><a href="/contact">Contact Us</a></li>
</ul>
@yield('main')
</body>
</html>
index.blade.php
@extends('layout')
@section('main')
<h1>Welcome to my First Blog with Laravel.</h1>
<p>Welcome to my First Blog with Laravel.Welcome to my First Blog with Laravel.Welcome to my First Blog wi</p>
@stop
about.blade.php
@extends('layout')
@section('main')
<h1>About This Blog.</h1>
<p>Welcome to my First Blog with Laravel.Welcome to my First Blog with Laravel.Welcome to my First Blog wi</p>
@stop
contact.blade.php
@extends('layout')
@section('main')
<h1>Contact Us</h1>
<p>Welcome to my First Blog with Laravel.Welcome to my First Blog with Laravel.Welcome to my First Blog wi</p>
@stop
routes.php文件
Route::get('/', function()
{
return View::make('index');
});
Route::get('about', function()
{
return View::make('about');
});
Route::get('contact', function()
{
return View::make('contact');
});
我的代码我是Laravel的新手我尝试使用Laravel Blade创建一个简单的布局但不幸的是当我点击我的“联系我们”,“关于我们”页面时,它不会重定向到以下网址并说找不到任何东西!我不明白以下代码有什么问题,请帮帮我 抱歉英语不好,并提前致谢。
答案 0 :(得分:1)
答案 1 :(得分:0)
试一试:
Route::get('/about', function()
{
return View::make('about');
});
Route::get('/contact', function()
{
return View::make('contact');
});
使用the&#34; /&#34;字符。
或更好:
{{HTML::link('about', 'About me')}}
修改强>
您可以执行以下操作:
<强> ROUTE:强>
Route::get('usuarios', array("before" => "inicio", function() {
return View::make('usuarios/lista'); /*The file lista.blade.php must exist in the "usuarios" directory, the "usuarios" directory must exist in the "view" directory.*/
}));
<强> HTML:强>
<a href="/usuarios">Usuarios</a>
试试吧。这对我有用。
如果这对你不起作用:也许你的错误在Apache配置中。
<VirtualHost *:80>
ServerName localhost
DocumentRoot /var/www/my_app/public
<Directory /var/www/my_app/public>
# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews
# Uncomment this if you're on Apache >= 2.4:
#Require all granted
</Directory>
</VirtualHost>