這篇文章主要介紹Laravel 7中Blade組件有哪些,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!

成都創(chuàng)新互聯(lián)公司是一家專注于成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站建設(shè)與策劃設(shè)計(jì),古縣網(wǎng)站建設(shè)哪家好?成都創(chuàng)新互聯(lián)公司做網(wǎng)站,專注于網(wǎng)站建設(shè)10年,網(wǎng)設(shè)計(jì)領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:古縣等地區(qū)。古縣做網(wǎng)站價(jià)格咨詢:13518219792
表單按鈕
開發(fā)一個(gè)應(yīng)用時(shí),如果您希望重定向并且做一些其他操作時(shí),不能使用簡(jiǎn)單的鏈接。GET 請(qǐng)求很容易受到 CSRF 攻擊。
相反,您應(yīng)該使用其他 HTTP 請(qǐng)求方式,使用表單和 CSRF 驗(yàn)證。 下面是一個(gè)在表單中生成按鈕的 FormButton 組件。
{{-- content of formButton.blade.php --}}
<form method="POST" action="{{ $action }}">
@csrf
@method($method ?? 'POST')
<button
type="submit"
class="{{ $class ?? '' }}"
>
{{ $slot }}
</button>
</form>您可以像這樣使用它:
// perform an action
<x-form-button :action="route('doSomething')">
Do something
</x-form-button>
// perform an action with another HTTP verb
<x-form-button :action="route('model.delete', $model)" method="delete">
Delete model
</x-form-button>導(dǎo)航欄
幾乎任何應(yīng)用程序都需要顯示某種導(dǎo)航,比如菜單和選項(xiàng)卡。這些導(dǎo)航鏈接是動(dòng)態(tài)的,這樣用戶就可以知道自己在應(yīng)用程序的哪個(gè)部分。
下面是可以展示鏈接的 navigationLink 組件。當(dāng)其以當(dāng)前請(qǐng)求的 URL 開始時(shí),它會(huì)自動(dòng)將自身設(shè)置為活動(dòng)狀態(tài)。
{{-- content of navigationLink.blade.php --}}
<li class="{{ \Illuminate\Support\Str::startsWith(request()->url(), $href) ? 'active' : '' }}">
<a href="{{ $href }}" @isset($dataDirtyWarn) data-dirty-warn @endisset>
{{ $slot }}
</a>
</li>這里是如何在 mailcoach.app 中使用它的。
<nav class="tabs">
<ul>
<x-navigation-item :href="route('mailcoach.emailLists.subscribers', $emailList)">
<x-icon-label icon="fa-users" text="Subscribers" :count="$emailList->subscribers()->count() ?? 0" />
</x-navigation-item>
<x-navigation-item :href="route('mailcoach.emailLists.tags', $emailList)">
<x-icon-label icon="fa-tag" text="Tags" />
</x-navigation-item>
<x-navigation-item :href="route('mailcoach.emailLists.segments', $emailList)">
<x-icon-label icon="fa-chart-pie" text="Segments" />
</x-navigation-item>
<x-navigation-item :href="route('mailcoach.emailLists.settings', $emailList)">
<x-icon-label icon="fa-cog" text="Settings" />
</x-navigation-item>
</ul>
</nav>這就是渲染的方法。
表單元素
Blade 組件會(huì)渲染出自適應(yīng)的表單元素。我們來看一下 textField 組件在 Mailcoach 中的用法。
<div class="form-row">
@if($label ?? null)
<label class="{{ ($required ?? false) ? 'label label-required' : 'label' }}" for="{{ $name }}">
{{ $label }}
</label>
@endif
@error($name)
<p class="form-error" role="alert">{{ $message }}</p>
@enderror
<input
autocomplete="off"
type="{{ $type ?? 'text' }}"
name="{{ $name }}"
id="{{ $name }}"
class="input"
placeholder="{{ $placeholder ?? '' }}"
value="{{ old($name, $value ?? '') }}"
{{ ($required ?? false) ? 'required' : '' }}
>
</div>正如你所看到的一樣,它渲染了標(biāo)簽、表單字段和可能的錯(cuò)誤。這就是它的用法。
<x-text-field label="Name" name="name" required />
以上是“Laravel 7中Blade組件有哪些”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!
分享文章:Laravel7中Blade組件有哪些
標(biāo)題來源:http://www.chinadenli.net/article46/gjoeeg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信小程序、建站公司、微信公眾號(hào)、全網(wǎng)營銷推廣、外貿(mào)網(wǎng)站建設(shè)、App開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)