有没有办法在 JavaScript 中动态检测 CSS 网格中元素所在的网格列和行?
我有一个网格,我设置了三个断点,使其具有 4、3 或 2 列。
我想要做的是,如果用户单击某个单元格,则将单元格中的新元素立即动态覆盖到被单击的单元格的右侧,除非它位于最右侧的列中,在这种情况下,覆盖元素将进入左侧的单元格。
我知道我可以使用grid-column和grid-row来指定我想要放入新内容的单元格,但为了能够使用它,我需要知道被单击的单元格的列和行。
我怎样才能动态地确定这一点?
我正在使用 create-react-app 开发 React 应用程序,最近我在 VS Code 终端中看到了一些对我来说有点可疑的错误。看起来一个名为“express”的库正试图找到一个win.ini文件和一些与/etc/passwd.
为什么它需要看那些?
我在 NPM 上查找了“express”,它看起来像一个轻量级的 Web 服务器。那是 create-react-app 用作开发服务器的吗?
URIError: Failed to decode param '/%c0%2e%c0%2e/%c0%2e%c0%2e/%c0%2e%c0%2e/%c0%2e%c0%2e/windows/win.ini'
at decodeURIComponent (<anonymous>)
at decode_param (C:\path\to\my\project\node_modules\express\lib\router\layer.js:172:12)
at Layer.match (C:\path\to\my\project\node_modules\express\lib\router\layer.js:123:27)
at matchLayer (C:\path\to\my\project\node_modules\express\lib\router\index.js:574:18)
at next (C:\path\to\my\project\node_modules\express\lib\router\index.js:220:15)
at expressInit (C:\path\to\my\project\node_modules\express\lib\middleware\init.js:40:5)
at Layer.handle [as handle_request] (C:\path\to\my\project\node_modules\express\lib\router\layer.js:95:5)
at trim_prefix (C:\path\to\my\project\node_modules\express\lib\router\index.js:317:13)
at C:\path\to\my\project\node_modules\express\lib\router\index.js:284:7
at Function.process_params (C:\path\to\my\project\node_modules\express\lib\router\index.js:335:12)
at next (C:\path\to\my\project\node_modules\express\lib\router\index.js:275:10)
at query (C:\path\to\my\project\node_modules\express\lib\middleware\query.js:45:5)
at Layer.handle [as handle_request] (C:\path\to\my\project\node_modules\express\lib\router\layer.js:95:5)
at trim_prefix (C:\path\to\my\project\node_modules\express\lib\router\index.js:317:13)
at C:\path\to\my\project\node_modules\express\lib\router\index.js:284:7
at Function.process_params (C:\path\to\my\project\node_modules\express\lib\router\index.js:335:12)
URIError: Failed to decode …Run Code Online (Sandbox Code Playgroud) 假设我希望能够通过指定用户ID 或指定其他标识符(例如电子邮件地址)来查询用户。
您如何构造根Query对象以接受它?
鉴于这种
public class MyQuery : ObjectGraphType
{
public MyQuery(IUserService userService)
{
Name = "Query";
Field<UserType>(
"user",
arguments: new QueryArguments(
new QueryArgument<IntGraphType>() { Name = "id" },
new QueryArgument<StringGraphType>() { Name = "email" }
),
resolve: context =>
{
int? id = context.GetArgument<int>("id");
if (id != null)
{
return userService.GetUserById(id);
}
string email = context.GetArgument<string>("email");
if (email != null)
{
return userService.GetUserByEmail(email);
}
return null;
}
);
}
}
Run Code Online (Sandbox Code Playgroud)
这是正确的方法吗?如果在查询中找不到参数,是否会context.GetArgument()返回null?还是提供两个参数来QueryArguments表示查询需要两个参数?
我正在使用语义 UI React。我有一个 Segment 组件,里面有一些东西,最后是一个我想向右浮动的按钮,但是当我向右浮动它时,它开始从 Segment 中出来:
如果我不浮动它,它会很好地留在段内,但它在左侧,我希望它在右侧:
我可以做什么来解决这个问题?