我正在尝试计算用户打开特定屏幕时的时间,当他进入屏幕时时间开始,当我退出屏幕时时间停止并给出在屏幕上花费的时间
这是我的代码:
componentDidMount = () => {
let date = new Date();
let hours = date.getHours();
let minutes = date.getMinutes();
let seconds = date.getSeconds();
this.setState({
startHour: hours,
startMin: minutes,
startSeconds: seconds,
});
}
Run Code Online (Sandbox Code Playgroud)
这是 ComponentWillunmount
componentWillUnmount() {
let date = new Date();
let endHours = date.getHours();
let endMinutes = date.getMinutes();
let endSeconds = date.getSeconds();
console.log(`${endHours}:${endMinutes}:${endSeconds}`);
console.log(
`${this.state.startHour}:${this.state.startMin}:${this.state.startSeconds}`,
);
Run Code Online (Sandbox Code Playgroud)
}
我有三个数组,我必须通过 Axios 将它们发送到 formdata 中。数组的键是record[]。但是我有三个数组,但我只有一个键,如何在同一个键上发送三个数组记录[]
这是我的代码
const params = new FormData();
params.append("record[]", this.props.addedOrders);
params.append("record[]", this.props.addedCustomers);
params.append("record[]", this.props.addedRecovery);
Run Code Online (Sandbox Code Playgroud)