react中类似template #button span class=btn-send发送验证码span template
在React中,可以使用Fragment或者函数组件来实现类似于Vue中的标签。
使用Fragment的方式如下:
import React, { Fragment } from 'react';
const App = () => {
return (
<Fragment>
<span className="btn-send">发送验证码</span>
</Fragment>
);
};
export default App;
使用函数组件的方式如下:
import React from 'react';
const ButtonTemplate = () => {
return (
<span className="btn-send">发送验证码</span>
);
};
export default ButtonTemplate;
然后在父组件中使用
原文地址: https://www.cveoy.top/t/topic/iXKv 著作权归作者所有。请勿转载和采集!