【问题标题】:Laravel blade not showing CSS on specific pageLaravel 刀片未在特定页面上显示 CSS
【发布时间】:2020-01-07 12:59:51
【问题描述】:

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

【问题讨论】:

  • 请显示您加载css的代码。
  • 我在公共/资产中的所有 CSS,例如
  • 请编辑您的问题并将代码发布到您加载 css 的位置。这可能是唯一需要的代码
  • 请尝试在你的href中添加一个斜线,即:&lt;link href="/assets或者更好地使用laravelasset()helper
  • 我猜没问题。 2刀片文件在同一文件夹中。并扩展相同的代码。应该加载资产。

标签: php laravel laravel-blade laravel-6


【解决方案1】:

恕我直言,如果您使用 asset() helper 加载您的资产会更好,例如:

<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 中阅读href= 的各种类型的相对和绝对 URL,以及哪些更好用。

【讨论】:

    猜你喜欢
    • 2021-12-26
    • 2021-09-20
    • 2018-12-12
    • 1970-01-01
    • 1970-01-01
    • 2019-06-28
    • 1970-01-01
    • 2016-06-26
    • 2023-04-08
    相关资源
    最近更新 更多