我无法弄清楚如何渲染轮廓输入类型(与文本蒙版一起使用时的标准 Material-UI 输入样式之一)。
我从这里复制了代码示例: https: //material-ui.com/components/text-fields/ 但它只提供了常规(下划线)输入的示例,但没有提供任何概述。
这就是我正在尝试做的事情,但它不起作用:
const ExpirationMask = props => {
const { inputRef, ...other } = props
return <MaskedInput
{...other}
ref={ref => {inputRef(ref ? ref.inputElement : null)}}
mask={[/\d/, /\d/,'/' ,/\d/, /\d/]}
placeholderChar={'\u2000'}
/>
}
<FormControl
variant='outlined' //this doesnt work
fullWidth
>
<InputLabel>Expiration</InputLabel>
<Input
value={ccExpiration}
onChange={(e, v) => setCCExpiration(e.target.value)}
placeholder='MM/YY'
variant='outlined' //this doesnt work either
inputComponent={ExpirationMask}
/>
</FormControl>
Run Code Online (Sandbox Code Playgroud) 我正在尝试从存储为 unsigned tinyint 的数据库中选择数字但在输出中我需要它们为负数。
这就是我所做的:
SELECT
-CAST(sales_shipments_items.qty AS SIGNED INTEGER) AS qty,
FROM sales_shipments_items
WHERE 1
Run Code Online (Sandbox Code Playgroud)
& 这适用于我的本地机器上的 mysql 5.5.25 但是在服务器上返回 0 的 mysql 5.5.32-cll-lve
顺便说一句,在我的本地机器上,我什至不必使用 CAST 它在没有它的情况下工作。
我尝试使用 CONVERT 而不是 CAST 但仍然只得到 0
样本数据 sales_shipments_items
id|type|shp_num|qty
3 1 3321 2
4 1 3322 2
5 2 3321 2
6 3 3320 1
7 4 3350 1
8 5 3351 3
Run Code Online (Sandbox Code Playgroud)
我期待看到:
-2
-2
-2
-1
-1
-3
Run Code Online (Sandbox Code Playgroud) 我需要能够将存储在"datetime"字段中的MySQL数据库中提取的数据转换为Java ZonedDateTime对象.
ZonedDateTime dt = ZonedDateTime.ofInstant(rs.getTimestamp("Start").toInstant(), UTC_ZONE_ID)
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是在我不需要toInstant()的Timestamp对象上添加本地时间偏移,因为日期时间已经以UTC格式存储在数据库中.所以当我运行以下代码时:
ZonedDateTime startDT =
ZonedDateTime.ofInstant(rs.getTimestamp("Start").toInstant(),Globals.LOCALZONEID);
System.out.println(rs.getTimestamp("start"));
System.out.println(rs.getTimestamp("start").toInstant());
Run Code Online (Sandbox Code Playgroud)
我明白了:
2017-06-08 13:15:00.0
2017-06-08T17:15:00Z
Run Code Online (Sandbox Code Playgroud)
我需要时间组件保持不变.
我无法找到任何明显的问题解决方案,所以我在这里遗漏了什么?
我的目标是编写一个中间件,负责记录对我的 API 的请求以及 API 对数据库中这些请求的响应。我已经制作了一个以类似方式处理异常的中间件,但我对此感到困惑。当你阅读有关中间件的 MSDN 时,你可以看到这张漂亮的图片:
这让您认为中间件 2 接收请求,对其进行某些操作并将其传递到中间件 3,然后一旦中间件 3 完成所有处理,它将控制权传递回中间件 2 进行其他处理。
我唯一不明白的是,如果 Middleware 2 Invoke() 方法仅在请求期间调用一次并且在响应期间不调用,如何记录响应?
启动.cs:
app.UseMiddleware<RequestLoggingMiddleware>();
Run Code Online (Sandbox Code Playgroud)
中间件:
public class RequestLoggingMiddleware
{
private readonly RequestDelegate nextMiddleware;
public RequestLoggingMiddleware(RequestDelegate nextMiddleware)
{
this.nextMiddleware = nextMiddleware;
this.options = options;
}
public async Task Invoke(HttpContext context)
{
System.Diagnostics.Debug.WriteLine("Middleware runs");
await nextMiddleware(context);
}
}
}
Run Code Online (Sandbox Code Playgroud)
在上面的示例中,我仅在初始请求期间但在做出响应之前在控制台中看到“中间件运行”一次。如何让它在响应周期内运行?