Renders a link formatted to call a phone number (tel:
link).
- Use
phone
to create a<a>
element with an appropriatehref
attribute. - Render the link with
children
as its content.
代码实现
const Callto = ({ phone, children }) => {
return <a href={`tel:${phone}`}>{children}</a>;
};
使用样例
ReactDOM.createRoot(document.getElementById('root')).render(
<Callto phone="+302101234567">Call me!</Callto>
);