【发布时间】:2021-08-03 13:33:50
【问题描述】:
有没有办法可以在 componentDidmount 中设置条件语句,如果付款方式是卡,它将显示卡号?我正在使用一个多数据表
componentDidMount() {
try {
firestore
.collection("orders")
.onSnapshot((snapshot) => {
const orders = [];
const data = doc.data();
orders.push({
"Order ID": doc.id,
"Payment method": data.paymentMethod.toUpperCase(),
{data.paymentMethod == "card" ? (
): (
)},
});
});
this.setState({ orders: orders });
});
} catch (err) {
console.log(err);
}
}
render() {
return this.state.orders ? (
<div>
<MUIDataTable
title={"Preparing"}
columns={this.columns}
data={this.state.orders}
options={this.options}
/>
</div>
) : (
<p>Loading...</p>
);
}
}
【问题讨论】:
-
“显示卡号”是什么意思?你的意思是渲染输出吗?
-
@evolutionxbox 是
-
使用状态?设置然后在渲染中显示的东西?请您也向我们展示您的渲染方法。
-
@evolutionxbox 已经编辑过了
-
支付方式为“卡”时,你想显示什么?
标签: javascript reactjs firebase google-cloud-firestore mui-datatable