<div class="cart-thead"> <div class="t-checkbox"> <input type="checkbox" name="" id="" class="checkall"> 全选 </div> <div class="t-goods">商品</div> <div class="t-price">单价</div> <div class="t-num">数量</div> <div class="t-sum">小计</div> <div class="t-action">操作</div> </div>改成组件
时间: 2024-03-25 10:37:53 浏览: 94
含checkbox的多选下拉组件
5星 · 资源好评率100%
好的,我可以帮你将这段代码改成一个组件,你可以参考下面的代码:
```js
// CartThead.js
import React from 'react';
function CartThead() {
return (
<div className="cart-thead">
<div className="t-checkbox">
<input type="checkbox" name="" id="" className="checkall" /> 全选
</div>
<div className="t-goods">商品</div>
<div className="t-price">单价</div>
<div className="t-num">数量</div>
<div className="t-sum">小计</div>
<div className="t-action">操作</div>
</div>
);
}
export default CartThead;
```
然后在其他组件中引入 `CartThead` 组件即可:
```js
// OtherComponent.js
import React from 'react';
import CartThead from './CartThead';
function OtherComponent() {
return (
<div>
<CartThead />
{/* 其他内容 */}
</div>
);
}
export default OtherComponent;
```
阅读全文