There is a React component that accepts a string as a property:
interface MyProps { myInput: string; } export function MyComponent({ myInput }: MyProps) { ... return ( <div> {myInput} </div> ); };
This component is used elsewhere:
<MyComponent myInput="请通过test@test.com与我们联系" />
My question is, can we change the color of the email address in this case? For example, change it to blue.
Or better yet, wrap that text in:
<a href="mailto:test@test.com" target="_blank"> test@test.com </a>
Not sure if something like this is possible if the type of the property is string
.
You can do this based on the string provided, but it's easier if you provide the email address as a separate property on
MyComponent
.Without changing the components, I would use some simple regex to get the email address from a string and then you can do whatever you want.
The following is a simple and incomplete regular expression example:
This is a very simplified solution, but I think you can use it in your case.