虽然我用 装饰了我的Datetime
财产BsonDateTimeOptions
,但它仍然不起作用,时间插入到数据库中,比我的当地时间晚 3 小时。(我认为是 utc)
我的基础抽象类
public abstract class MongoBaseModel
{
public ObjectId Id { get; set; }
[BsonElement]
[BsonDateTimeOptions(Kind = DateTimeKind.Local)]
public DateTime InsertedAt{ get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我的实体
public class RockSongs:MongoBaseModel
{
[BsonElement("Name")]
public string Name { get; set; }
[BsonElement("Singer")]
public string Singer { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
数据库版本 v4.2.1
MongoDb.Driver 2.7.2
我是 React 和 Typescript 的新手。在 AlertDismissable 类中,我正在设置请求完成时显示的属性。我已经使用了这个示例并对其进行了一些更改。
根据响应,我更改 AlertDismissable 的内容和样式。
当用户单击隐藏按钮时,我尝试将其显示属性设置为 false。我已将状态与属性绑定在一起,这就是我尝试设置 props 的原因。但是,编译器会抛出异常
TS2540:无法分配给“show”,因为它是常量或只读属性。(handleDismiss 方法)
看来通用道具默认是只读的。还有其他方法可以使其工作吗?
这是我的 AlertDismissable tsx
import * as React from 'react'
import { Alert, Button } from 'react-bootstrap';
interface AlertDismissableState {
show: boolean;
style: string;
}
export default class AlertDismissable extends React.Component<AlertDismissableState, AlertDismissableState> {
constructor(props: any, context: any) {
super(props, context);
this.handleDismiss = this.handleDismiss.bind(this);
this.handleShow = this.handleShow.bind(this);
this.state = {
show: this.props.show,
style: this.props.style
};
}
handleDismiss() {
this.props.show=false;
}
handleShow() {
this.props.show=true;
}
render() …
Run Code Online (Sandbox Code Playgroud)