ผนวกรวมแอททริบิวต์ต่างๆ-ฉันจะทำให้พวกเขาต้องฟังก์ชันเหมาะสม?

0

คำถาม

ฉันต้องต่อไปนี้ในส่วนประกอบถูกจัดเก็บไว้ใน resources/views/components/green-button.blade.php ใน laravel 8.

<button {{ $attributes->merge(['type' => 'button', 'class' => 'px-4 inline-flex justify-center py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-green-600 hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-500']) }}>
    {{ $slot }}
</button>

ฉันใช้มัน:

<x-green-button class="px-0"
                title="Click to show or hide data entry for {{$person->firstname}}."
                wire:click="toggleVisibility({{$person->id}})">
  <h3 class="my-1">{{$person->FullName_fh}}</h3>
</x-green-button>

ที่ส่วนประกอบที่มีข้อบแกน x นุ่นช่วยของพิกเซล-4. ฉันขอผ่านพิกเซล-0 แต่มันไม่มีผลกระทบ ฉันทำอะไรผิดเหรอ?

rbd

components laravel
2021-11-18 22:02:46
1

คำตอบที่ดีที่สุด

1

คุณสามารถใช้ @props() เพื่อให้บรรลุจุดมุ่งหมาย

// In your component

@props(['customClass' => ''])

<button {{ $attributes->merge([
    'type'  => 'button', 
    'class' => 'all-your-classes ' . $customClass
]) }}>
    {{ $slot }}
</button>
// In your blade file

<x-green-button customClass="px-0">
    {{ $person->FullName_fh }}
</x-green-button>

2021-11-18 22:15:11

สวัสดี thx. ถ้า'ทั้งหมดของคุณ-ชั้นเรียน'มีการ'พิกเซล-4'อยู่ในมันและ$customClass='พิกเซล-0'จะคนพิกเซล-4 พา precedence เพราะมันมาก่อนไหม?, หรือว่าสุดท้ายที่ขัดแย้งในชั้นเรียนใช้ precedence? Thx เอส
Robert Bryan Davis

@RobertBryanDavis มันขึ้นอยู่กับรูปแบบสไตล์ชีตเพื่อดู: stackoverflow.com/a/3066365/13916713
Samuel Ferdary

สวัสดี thx สำหรับฟิตแบก ฉัฝ่ายใดได้ประโยชน์สูง funcctionality ฉันค้นหาโดยการใช้บพวกอุปกรณ์ประกอบ()และจากไปในการปรับเปลี่ยนเพื่อรูปแบบทางนั้น
Robert Bryan Davis

ในภาษาอื่นๆ

หน้านี้อยู่ในภาษาอื่นๆ

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................

ดังอยู่ในนี้หมวดหมู่

ดังคำถามอยู่ในนี้หมวดหมู่