亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

搜索
博主信息
博文 37
粉絲 0
評(píng)論 1
訪問(wèn)量 36597
最新下載
更多>
網(wǎng)站特效
網(wǎng)站源碼
網(wǎng)站素材
前端模板
分別創(chuàng)建控制器、視圖、路由文件和控制器中模擬數(shù)據(jù),并把數(shù)據(jù)渲染到視圖中 以及使用@include將頁(yè)面的header部分放到public/header.php中-2019-11-04
H先生
原創(chuàng)
903人瀏覽過(guò)

1、分別創(chuàng)建控制器、視圖、路由文件


實(shí)例

<?php

namespace App\Http\Controllers\admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class Home extends Controller
{
    public function index(){
        $data['title'] = '2019大閱兵';
        return view('admin/home/index',$data);
    }

}
?>

運(yùn)行實(shí)例 ?

點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例


實(shí)例

<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});

Route::get('/304525', function () {
    // 讀取數(shù)據(jù)
    $article = array('title'=>'2019國(guó)慶大閱兵','detail'=>'獎(jiǎng)勵(lì)上級(jí)阿薩德老費(fèi)勁啊勝利大街愛(ài)上了就發(fā)了房間里睡大覺(jué)','auth'=>array('username'=>'admin','age'=>18));
    return view('article/detail',$article);
});

Route::get('/home','home@index');

Route::get('/article/detail',function (){
    return ('<div style="margin: 10px auto;text-align:center; font-weight: bold;color: red;">新聞列表</div>');
});

Route::get('/admin/home/index','admin\Home@index');
?>

運(yùn)行實(shí)例 ?

點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例





實(shí)例

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <div style="text-align: center;">{{$title}}</div>
</body>
</html>

運(yùn)行實(shí)例 ?

點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例

1.png









2、在控制器中模擬數(shù)據(jù),并把數(shù)據(jù)渲染到視圖中



實(shí)例

<?php

namespace App\Http\Controllers\admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class Home extends Controller
{
    public function index(){
        $data['navs'] = array(array('title'=>'企業(yè)logo','url'=>'/'),array('title'=>'新聞資訊','url'=>'/'),array('title'=>'最新產(chǎn)品','url'=>'/'));
        return view('admin/home/index',$data);
    }

}
?>

運(yùn)行實(shí)例 ?

點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例


1.png








 3、使用@include將頁(yè)面的header部分放到public/header.php中

1.png


實(shí)例

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>企業(yè)站</title>
    <style>
        .header{background-color: #000;width: 100%;height: 50px;
            text-align: center;}
        .header a{line-height: 50px;color: #fff;margin: 0 20px;text-decoration: none;}
        .nav-left{width: 200px;height: 500px;background-color: red;float:left;}
        .news{width: 300px;height: 500px;background-color: green;float:left;}
    </style>
</head>
<body>
    {{--header導(dǎo)航--}}
    @include('admin/public/header')
    {{--left導(dǎo)航--}}
    <div class="nav-left"></div>

    {{--right 文字列表--}}
    <div class="news"></div>
</body>
</html>

運(yùn)行實(shí)例 ?

點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例



實(shí)例

<?php

namespace App\Http\Controllers\admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class Home extends Controller
{
    public function index(){
        $data['navs'] = array(array('title'=>'企業(yè)logo','url'=>'/'),array('title'=>'新聞資訊','url'=>'/'),array('title'=>'最新產(chǎn)品','url'=>'/'));
        return view('admin/home/index',$data);
    }

}
?>

運(yùn)行實(shí)例 ?

點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例


實(shí)例

<div class="header">
    @foreach($navs as $nav){
    <a href="{{$nav['url']}}">{{$nav['title']}}</a>
    }
    @endforeach
</div>

運(yùn)行實(shí)例 ?

點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例





批改狀態(tài):合格

老師批語(yǔ):寫(xiě)得很認(rèn)真, 命令創(chuàng)建效率和正確率要優(yōu)于手工
本博文版權(quán)歸博主所有,轉(zhuǎn)載請(qǐng)注明地址!如有侵權(quán)、違法,請(qǐng)聯(lián)系admin@php.cn舉報(bào)處理!
全部評(píng)論 文明上網(wǎng)理性發(fā)言,請(qǐng)遵守新聞評(píng)論服務(wù)協(xié)議
0條評(píng)論
作者最新博文
關(guān)于我們 免責(zé)申明 意見(jiàn)反饋 講師合作 廣告合作 最新更新
php中文網(wǎng):公益在線php培訓(xùn),幫助PHP學(xué)習(xí)者快速成長(zhǎng)!
關(guān)注服務(wù)號(hào) 技術(shù)交流群
PHP中文網(wǎng)訂閱號(hào)
每天精選資源文章推送
PHP中文網(wǎng)APP
隨時(shí)隨地碎片化學(xué)習(xí)
PHP中文網(wǎng)抖音號(hào)
發(fā)現(xiàn)有趣的

Copyright 2014-2025 http://ipnx.cn/ All Rights Reserved | php.cn | 湘ICP備2023035733號(hào)

  • 登錄PHP中文網(wǎng),和優(yōu)秀的人一起學(xué)習(xí)!
    全站2000+教程免費(fèi)學(xué)