Laravel 第一个视图

来源:互联网 发布:全国省市区sql 编辑:程序博客网 时间:2024/05/01 18:52

在app/routes.php中写入以下代码,

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

意思是使用视图生成html代码来响应users这个地址

在app/views下建立两个文件layout.blade.php users.blade.php
为什么建立两个文件夹是因为,user.blade.php要用到layout.blade.php中的内容,有点像母版页的概念(.net 2.0中引入的概念),又有点像类的继承的感觉
里边都是文本,不需要加<?php ?>

layout.blade.php

<html>    <body>        <h1>Laravel Quickstart</h1>        @yield('content')    </body></html>
users.blade.php


@extends('layout')@section('content')    Users!@stop

视图是用 Blade的模板引擎,对这个引擎的了解的比较少也不知道他的历史

0 0
原创粉丝点击