首页 > 解决方案 > Laravel 刀片未在特定页面上显示 CSS

问题描述

Laravel 6.0 不显示特定页面的 css。其他页面运行顺畅。这是我的代码“satisekle.blade.php 和 edit.blade.php 几乎相同的页面。唯一的区别是一些变量。php 代码正在运行,但未加载 css。我在 public/assets 中的资产文件夹

<link rel="shortcut icon" href="assets/dist/img/ico/favicon.png" type="image/x-icon">

    <!-- jquery-ui css -->
    <link href="assets/plugins/jquery-ui-1.12.1/jquery-ui.min.css" rel="stylesheet" type="text/css"/>
    <!-- Bootstrap -->
    <link href="assets/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
    <!-- Bootstrap rtl -->
    <!--<link href="assets/bootstrap-rtl/bootstrap-rtl.min.css" rel="stylesheet" type="text/css"/>-->
    <!-- Lobipanel css -->
    <link href="assets/plugins/lobipanel/lobipanel.min.css" rel="stylesheet" type="text/css"/>
    <!-- Pace css -->
    <link href="assets/plugins/pace/flash.css" rel="stylesheet" type="text/css"/>
    <!-- Font Awesome -->
    <link href="assets/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css"/>
    <!-- Pe-icon -->
    <link href="assets/pe-icon-7-stroke/css/pe-icon-7-stroke.css" rel="stylesheet" type="text/css"/>
    <!-- Themify icons -->
    <link href="assets/themify-icons/themify-icons.css" rel="stylesheet" type="text/css"/>

<head>
    @include('partials._head')
</head>
<body class="hold-transition sidebar-mini">
@include('partials.topbar')
<div class="container" id="contentall">
    <div class="content">
        @include('partials.leftbar')
        @yield('content')
    </div>
</div>
</body>

@include('partials.javascript')

@extends('main')
@section('content')
    <form action="{{ route('satislar.store') }}" method="post">
        {{ csrf_field() }}
        <div class="form-group">
            <label for="exampleInputEmail1">Satış Takip Numarası</label>
            <input type="text" class="form-control" readonly value="{{$random}}" name="satis_takip_no">
            <small id="emailHelp" class="form-text text-muted">Random Atanan Unique Takip Numarası</small>
        </div>
        <div class="form-group">
            <label for="exampleInputEmail1">Ürün</label>
            <input type="text" class="form-control" required id="exampleInputEmail1" aria-describedby="emailHelp"
                   name="urun" placeholder="Ürün">*
            <small id="emailHelp" class="form-text text-muted">Ürün İsmini Giriniz</small>
        </div>
        <div class="form-group">
            <label for="exampleInputEmail1">Birim</label>
            <input type="text" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" name="birim"
                   placeholder="Birim">
            <small id="emailHelp" class="form-text text-muted">Ürün Miktarını Giriniz</small>
        </div>
        <div class="form-group">
            <label for="exampleInputEmail1">Firma Adı</label>
            <input type="text" class="form-control" required id="exampleInputEmail1" aria-describedby="emailHelp"
                   name="firma" placeholder="Firma Adı">*
            <small id="emailHelp" class="form-text text-muted">Firmanın Adını Giriniz</small>
        </div>
        <div class="form-group">
            <label for="exampleInputEmail1">Yetkili</label>
            <input type="text" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" name="yetkili"
                   placeholder="Yetkili">
            <small id="emailHelp" class="form-text text-muted">Teslim Alacak Yetkilinin İsmini Giriniz</small>
        </div>
        <div class="form-group">
            <label for="exampleInputEmail1">Telefon</label>
            <input type="text" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" name="telefon"
                   placeholder="Telefon">
            <small id="emailHelp" class="form-text text-muted">Ulaşılacak Kişinin Telefon Numarasını Giriniz</small>
        </div>
        <div class="form-group">
            <label for="exampleInputEmail1">E-Posta</label>
            <input type="email" class="form-control" id="exampleInputEmail1" required aria-describedby="emailHelp"
                   name="eposta" placeholder="E-Posta">*
            <small id="emailHelp" class="form-text text-muted">Satışı Takip edecek Kişinin E-postasını Giriniz</small>
        </div>
        <button type="submit" class="btn btn-primary">Gönder</button>
    </form>
@endsection

控制器

public function satisekle()
{
    $number = mt_rand(1000000000, mt_getrandmax());
    if ($this->sorgula($number) === "") {
        return $this->satisekle();
    }

    return view('satislar.satisekle')->with('random', $number);
}

public function edit($id)
{
    $satis = Satislar::find($id);

    return view('satislar.edit')->with('satis', $satis);
}

和路线;

Route::get('/satisekle', 'satislarController@satisekle');
Route::get('/index', 'satislarController@index');
Route::get('/satislar/{$id}/edit', 'satislarController@edit');

Route::resource('satislar', 'satislarController');

这是行不通的。不显示 css 我完全疯了;

@extends('main')


@section('content')

    <form action="{{ route('satislar.update',$satis->id)}}" method="post">
        @method('PUT')
        {{ csrf_field() }}
        <div class="form-group">
            <label for="exampleInputEmail1">Satış Takip Numarası</label>
            <input type="text"  class="form-control"  value="{{$satis->takip_no}}" name="satis_takip_no" readonly>
            <small id="emailHelp" class="form-text text-muted">Random Atanan Unique Takip Numarası</small>
        </div>

        <div class="form-group">
            <label for="exampleInputEmail1">Ürün</label>
            <input type="text" class="form-control" required id="exampleInputEmail1" value="{{$satis->urun}}" aria-describedby="emailHelp" name="urun" placeholder="Ürün">*
            <small id="emailHelp" class="form-text text-muted">Ürün İsmini Giriniz</small>
        </div>

        <div class="form-group">
            <label for="exampleInputEmail1">Birim</label>
            <input type="text" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" value="{{$satis->birim}}" name="birim" placeholder="Birim">
            <small id="emailHelp" class="form-text text-muted">Ürün Miktarını Giriniz</small>
        </div>

        <div class="form-group">
            <label for="exampleInputEmail1">Firma Adı</label>
            <input type="text" class="form-control"  id="exampleInputEmail1" aria-describedby="emailHelp" value="{{$satis->firma}}" name="firma" placeholder="Firma Adı" required>*
            <small id="emailHelp" class="form-text text-muted">Firmanın Adını Giriniz</small>
        </div>

        <div class="form-group">
            <label for="exampleInputEmail1">Yetkili</label>
            <input type="text" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" name="yetkili" value="{{$satis->yetkili}}" placeholder="Yetkili">
            <small id="emailHelp" class="form-text text-muted">Teslim Alacak Yetkilinin İsmini Giriniz</small>
        </div>
        <div class="form-group">
            <label for="exampleInputEmail1">Telefon</label>
            <input type="text" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" name="telefon" value="{{$satis->telefon}}" placeholder="Telefon">
            <small id="emailHelp" class="form-text text-muted">Ulaşılacak Kişinin Telefon Numarasını Giriniz</small>
        </div>
        <div class="form-group">
            <label for="exampleInputEmail1">E-Posta</label>
            <input type="email" class="form-control" id="exampleInputEmail1"  aria-describedby="emailHelp" name="eposta" value="{{$satis->eposta}}" placeholder="E-Posta" required>*
            <small id="emailHelp" class="form-text text-muted">Satışı Takip edecek Kişinin E-postasını Giriniz</small>
        </div>

        <button type="submit" class="btn btn-primary">Gönder</button>
    </form>
@endsection

标签: phplaravellaravel-bladelaravel-6

解决方案


恕我直言,如果您使用asset() 帮助程序加载资产会更好,例如:

<link rel="shortcut icon" href="{{ asset('dist/img/ico/favicon.png') }}" type="image/x-icon">
<!-- jquery-ui css -->
<link href="{{ asset('plugins/jquery-ui-1.12.1/jquery-ui.min.css') }}" rel="stylesheet" type="text/css"/>
<!-- Bootstrap -->
<link href="{{ asset('bootstrap/css/bootstrap.min.css') }}" rel="stylesheet" type="text/css"/>
<!-- Bootstrap rtl -->
<!--<link href="{{ asset('bootstrap-rtl/bootstrap-rtl.min.css') }}" rel="stylesheet" type="text/css"/>-->
<!-- Lobipanel css -->
<link href="{{ asset('plugins/lobipanel/lobipanel.min.css') }}" rel="stylesheet" type="text/css"/>
<!-- Pace css -->
<link href="{{ asset('plugins/pace/flash.css" rel="stylesheet') }}" type="text/css"/>
<!-- Font Awesome -->
<link href="{{ asset('font-awesome/css/font-awesome.min.css') }}" rel="stylesheet" type="text/css"/>
<!-- Pe-icon -->
<link href="{{ asset('pe-icon-7-stroke/css/pe-icon-7-stroke.css') }}" rel="stylesheet" type="text/css"/>
<!-- Themify icons -->
<link href="{{ asset('themify-icons/themify-icons.css') }}" rel="stylesheet" type="text/css"/>

您可以在这个SO question中阅读有关各种类型的相对和绝对 URLhref=以及哪些更好用。


推荐阅读