我想标题有点难以理解,所以我会解释.我想要达到这个效果:
(一个圆角及其边框,也有圆角边框).
我通过使用background-clip
属性设法做到了这一点:
(圆角为边框,但不是内框)
问题是,我怎样才能实现内盒的圆角?
谢谢!
编辑
我正在使用的HTML:
<header class="body template-bg template-border radius-all">
<nav>
<ul>
<li><a href="#">Link 1</a></li>
<li><a href="#">Link 2</a></li>
<li><a href="#">Link 3</a></li>
<li><a href="#">Link 4</a></li>
</ul>
</nav>
</header>
Run Code Online (Sandbox Code Playgroud)
而CSS:
.radius-all {
border-radius: 10px;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
}
.template-bg {
background: #FFF;
-moz-background-clip: padding;
-webkit-background-clip: padding;
background-clip: padding-box;
}
.template-border {
border: 5px solid rgba(255, 255, 255, 0.2);
}
Run Code Online (Sandbox Code Playgroud) 当查询为空时,有没有办法使用默认值?
如果我有以下 DTO 查询:
export class MyQuery {
readonly myQueryItem: string;
}
Run Code Online (Sandbox Code Playgroud)
我的请求不包含查询,那么myQuery.myQueryItem
将是未定义的。我如何使它具有默认值?
我正在尝试使用 aValidationPipe
但无论我如何编写代码,在发送请求时都会收到以下警告:No metadata found. There is more than once class-validator version installed probably. You need to flatten your dependencies
.
我的路线看起来像这样:
@Get()
@UsePipes(new ValidationPipe({ transform: true }))
async findAll(@Query() queryDto: QueryDto) {
return await this.myService.findAll(queryDto);
}
Run Code Online (Sandbox Code Playgroud)
我的 DTO 看起来像这样:
export class queryDto
{
@ApiModelProperty({
description: 'Maximum number of results',
type: Number,
example: 50,
default: 50,
required: false
})
readonly limit: number = 50;
}
Run Code Online (Sandbox Code Playgroud)
我尝试使用ValidationPipe
多种方法,遵循doc,但没有任何效果对我有用。我知道这是行不通的,因为虽然请求得到响应,默认值,我在我的DTO写的财产limit
,这是50
,是不是当查询是空的使用。因此,当limit
查询中提供no 时,limit …
我需要使用它$nextTick
来测试我的程序的某些部分。不知何故,它打破了我的测试并使它们始终成功 - 即使它们应该失败。
最小的测试样本如下所示:
import App from "./App";
import { shallowMount } from "@vue/test-utils";
it("should fail", () => {
const wrapper = shallowMount(App);
wrapper.vm.$nextTick(() => {
expect(1).toBe(3);
done();
});
});
Run Code Online (Sandbox Code Playgroud)
您可以在此处找到沙箱示例
如果打开控制台,您应该会发现以下错误消息:
[Vue warn]: Error in nextTick: "Error: expect(received).toBe(expected)
Error: expect(received).toBe(expected)
Run Code Online (Sandbox Code Playgroud)
为什么测试成功?为什么错误会被忽略?如果有这样的$nextTick
注释,我该如何正确使用?
我无法让类验证器工作。似乎我没有使用它:一切正常,就好像我没有使用类验证器一样。当发送带有格式不正确正文的请求时,我没有任何验证错误,尽管我应该。
我的 DTO:
import { IsInt, Min, Max } from 'class-validator';
export class PatchForecastDTO {
@IsInt()
@Min(0)
@Max(9)
score1: number;
@IsInt()
@Min(0)
@Max(9)
score2: number;
gameId: string;
}
Run Code Online (Sandbox Code Playgroud)
我的控制器:
@Patch('/:encid/forecasts/updateAll')
async updateForecast(
@Body() patchForecastDTO: PatchForecastDTO[],
@Param('encid') encid: string,
@Query('userId') userId: string
): Promise<ForecastDTO[]> {
return await this.instanceService.updateForecasts(userId, encid, patchForecastDTO);
}
Run Code Online (Sandbox Code Playgroud)
我的引导程序:
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.useGlobalPipes(new ValidationPipe());
await app.listen(PORT);
Logger.log(`Application is running on http://localhost:${PORT}`, 'Bootstrap');
}
bootstrap();
Run Code Online (Sandbox Code Playgroud)
我找不到问题所在。我错过了什么?
如何在包裹的弹性项目之间实现分隔符?
这是我要添加分隔符的代码示例:
.a {
display: flex;
flex-wrap: wrap;
justify-content: space-around;
}
.b {
background-color: #F6E0E0;
width: 105px;
height: 80px;
}
Run Code Online (Sandbox Code Playgroud)
<div class="a">
<div class="b">b</div>
<div class="b">b</div>
<div class="b">b</div>
<div class="b">b</div>
<div class="b">b</div>
<div class="b">b</div>
<div class="b">b</div>
<div class="b">b</div>
<div class="b">b</div>
<div class="b">b</div>
<div class="b">b</div>
<div class="b">b</div>
<div class="b">b</div>
<div class="b">b</div>
<div class="b">b</div>
</div>
Run Code Online (Sandbox Code Playgroud)
每个块应该通过分隔符与其左侧和右侧的块分隔开(例如,宽度为 1 像素、高度为 50 像素的 div 以及背景颜色)。但是,位于容器右边缘的一个块不应与位于容器左边缘和下一行的下一个块分隔开。由于换行是动态的(为了使样式流畅),我无法在特定位置添加分隔符。
我尝试使用边框或 div,但无法得到正确的结果。我还尝试了一种解决方法,将 justify-content 设置为 space- Between 并向分隔符添加 -1px 的 margin-right ,以便右侧的内容脱离容器,但我需要将 justify-content 设置为周围有空间,因此该解决方案无效。
我在C中编写一个使用头文件的程序.这些头文件包含一些结构声明,并且由于C结构和C++几乎相同,GitHub将这些文件识别为C++文件,而我希望它们被识别为C文件.
有没有办法强制GitHub将头文件识别为C文件而不是C++文件?
我想知道给定角度的椭圆上顶点的坐标。椭圆中心位于 x = 0 和 y = 0 处。长半轴为 x,值为 1。短半轴为 y,值为 0.38。角度是可变的。
我已经尝试了这个 Stack Exchange 帖子上的所有内容,但没有任何效果:https ://math.stackexchange.com/questions/22064/calculate-a-point-that-lies-on-an-ellipse-given-an-angle
可能不是给定的解决方案是错误的,而是我将它们集成在 JavaScript 中。
例如,这不起作用:
a = 1
b = 0.38
function getAngle(x1, y1, x2, y2) {
return Math.atan((y2 - y1) / (x2 - x1)) * 180 / Math.PI
}
angle = getAngle(0,0,0.3,0.7)
x = (a*b*Math.cos(angle))
/
Math.sqrt(
(a*Math.cos(angle))**2 +
(b*Math.sin(angle))**2
)
y = (a*b*Math.sin(angle))
/
Math.sqrt(
(a*Math.cos(angle))**2 +
(b*Math.sin(angle))**2
)
console.log({x,y})
Run Code Online (Sandbox Code Playgroud)
输出:
{
"x": -0.35112437558647797,
"y": -0.3823646436315567
}
Run Code Online (Sandbox Code Playgroud)
正如您在此图中看到的,结果不是椭圆上的顶点:
如何根据角度找到椭圆中一点的坐标?
在JS中,有undefined和null。undefined 表示“没有值”,null 表示“相当于空的值”。然而,在 Dart 中(可能在其他语言中,我不知道,但现在我正在使用 Dart),没有未定义的,只有 null。因此,不可能区分等同于空的价值和没有价值。
Dart 中有模拟这种差异的标准方法吗?
我在调试SDL2程序时遇到了困难:当我打印诸如SDL_EventType
或的枚举SDL_Keycode
值时,显示的值非常高并且彼此不同.例如,事件类型SDL_KEYDOWN
对应于768 - 枚举中没有769个元素SDL_EventType
!
我做了一个小测试,看看这个奇怪的行为是否是由于我的程序,但行为仍然存在:
#include <stdio.h>
#include "SDL.h"
int main(int argc, char *argv[])
{
SDL_Init(SDL_INIT_VIDEO);
SDL_Event event;
SDL_Window *wind = SDL_CreateWindow("ee", 700, 100, 300, 300, 0);
while (SDL_PollEvent == 1)
SDL_PollEvent(&event);
while (1)
{
SDL_PollEvent(&event);
if (event.type == SDL_QUIT || event.key.keysym.sym == SDLK_ESCAPE)
break;
fprintf(stderr, "type = %d\n", event.type);
event.type = 0;
SDL_Delay(15);
}
printf("%d\n", SDL_GetTicks());
SDL_Quit();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
打印SDLK_DOWN
,SDL_MOUSEMOTION
或这样的关键字输出比以前的方案,这是相干相同的结果.但为什么这些值与枚举类型不一致?
我无法更改状态栏颜色,似乎是因为 AppBar 一直覆盖它。
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(), // this component sets a status bar color and brightness
body: AnnotatedRegion<SystemUiOverlayStyle>( // this component fails to
// override the status bar color
// and brightness set by the AppBar
value: SystemUiOverlayStyle(
statusBarColor: Colors.blue,
statusBarIconBrightness: Brightness.light
),
child: Container()
)
);
}
Run Code Online (Sandbox Code Playgroud)
当我注释掉 AppBar 时,状态颜色变为蓝色。当我取消注释时,状态栏颜色保持蓝色,但无法再次更改。似乎 AppBar 锁定了当前颜色。
在子小部件中,我在返回组件之前尝试使用setSystemUIOverlayStyle但它没有帮助:
Widget build(BuildContext context) {
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
statusBarColor: Colors.blue,
statusBarIconBrightness: Brightness.light
));
return Container();
}
Run Code Online (Sandbox Code Playgroud)
有AppBar时如何设置状态栏颜色?