แก้ไขแล้ว: เปลี่ยนสีของการขีดฆ่าผ่านบรรทัดข้อความในการตอบสนองแบบเนทีฟ

ปัญหาหลักในการเปลี่ยนสีของสไตรค์ผ่านบรรทัดข้อความใน React Native คือการยากที่จะได้เอฟเฟกต์ที่ต้องการ

I have a text component in React Native and I want to change the color of the strike through line. How can I do this?


A:

You can use the <code>textDecorationColor</code> style property: https://facebook.github.io/react-native/docs/text-style-props#textdecorationcolor
<code>&lt;Text style={{ textDecorationLine: 'line-through', textDecorationColor: 'red' }}&gt;Hello world!&lt;/Text&gt;</code>

ตอบโต้ Native Strikethrough Text โดยใช้ StyleSheet

ใน React Native คุณสามารถใช้คุณสมบัติ styleSheet ขององค์ประกอบ Text เพื่อใช้สไตล์กับข้อความ

หากต้องการใช้คุณสมบัติ styleSheet คุณต้องสร้างวัตถุ StyleSheet ก่อน จากนั้น คุณสามารถใช้คุณสมบัติ styleSheet เพื่อนำสไตล์ไปใช้กับข้อความได้

นี่คือตัวอย่างวิธีใช้คุณสมบัติ styleSheet เพื่อใช้สไตล์กับข้อความใน React Native:

นี่คือข้อความบางส่วนที่มีสไตล์

กระทู้ที่เกี่ยวข้อง:

แสดงความคิดเห็น