嗨,我有 Nest 应用程序 dto:
export class TestDto {
@IsNotEmpty()
id: number;
@IsNotEmpty()
slug: string;
@IsNotEmpty()
size: number;
}
Run Code Online (Sandbox Code Playgroud)
和发布请求:
@Post(':id/start')
async startTest(
@Param('id') id: number,
@Request() req,
@Body() testDto?: TestDto
): Promise<RoomDto | string> {
return await this.roomsService.startTest(id, testDto);
}
Run Code Online (Sandbox Code Playgroud)
我希望 body 中的 testDto 可选,但在发送请求时出现错误:
{
"statusCode": 400,
"message": [
"slug should not be empty",
"size should not be empty"
],
"error": "Bad Request"
}
Run Code Online (Sandbox Code Playgroud)
如何实现这样的目标?
我想提高我的谷歌页面速度结果。我发现我的主要问题之一是累积布局移位。我意识到这个问题是由cookies和促销弹出窗口引起的。
您对如何解决此谷歌页面速度问题有什么建议吗?我认为延迟渲染 cookies 弹出窗口是不正确的,谷歌可以检查这一点并将其标记为问题。
我有一个看起来像这样的数组:
var myDates = ["2017-12-01 08:44:49", "2017-12-03 08:54:49", "2018-01-03 10:54:43"]
Run Code Online (Sandbox Code Playgroud)
我想创建名为Moth的新数组,即.
var myMonths = [
'December', 'March', 'January']
];
Run Code Online (Sandbox Code Playgroud)
我怎么能做到这一点?
我可以使用以下内容在一个字符串上执行此操作:
var oneMonth = "2017-12-01 08:44:49";
var str = oneMonth.substring(5,7);
var months = [
'January', 'February', 'March', 'April', 'May',
'June', 'July', 'August', 'September',
'October', 'November', 'December'
];
var saleMonths = months[str-1];
console.log(saleMonths);
Run Code Online (Sandbox Code Playgroud) 我有一个这样的字符串:2017-12-01 08:44:49我想从字符串中得到月份的名称.
我做了什么:
var myMonth = '2017-12-01 08:44:49';
var str = myMonth.substring(5,7);
var months = [
'January', 'February', 'March', 'April', 'May',
'June', 'July', 'August', 'September',
'October', 'November', 'December'
];
Run Code Online (Sandbox Code Playgroud)
我不知道如何将这个值(即12)归结为几个月(我不想在条件限制时创建12个).