我无法让媒体查询与媒体模板和样式组件一起使用。我直接从文档中定义了一个 MediaQueries 模板:
import { css } from "styled-components";
const sizes = {
desktop: 992,
tablet: 768,
phone: 576
};
// Iterate through the sizes and create a media template
const media = Object.keys(sizes).reduce((acc, label) => {
acc[label] = (...args) => css`
@media (max-width: ${sizes[label] / 16}em) {
${css(...args)}
}
`;
return acc;
}, {});
export default media;
Run Code Online (Sandbox Code Playgroud)
这是测试文件:
import React from "react";
import styled from "styled-components";
import media from "./MediaQueries";
const Desktop = styled.h1`
color: red;
${media.phone` …Run Code Online (Sandbox Code Playgroud) 我正在尝试用 React 重新创建一个类似记忆的游戏。我正在使用 Redux Toolkit 进行状态管理,但我在处理一个用例时遇到了问题。
在 selectCard 操作中,我想将所选卡添加到商店,并检查是否已选择其中 2 张。如果是这样,我想selected在延迟后清空数组。
const initialState : MemoryState = {
cards: [],
selected: [],
}
const memorySlice = createSlice({
name: 'memory',
initialState: initialState,
reducers: {
selectCard(state: MemoryState, action: PayloadAction<number>) {
state.selected.push(action.payload);
if (state.selected.length === 2) {
setTimeout(() => {
state.selected = [];
}, 1000);
}
}
}
});
Run Code Online (Sandbox Code Playgroud)
卡片被选择得很好,但是当我选择 2 时,1 秒后我收到此错误:
TypeError: Cannot perform 'set' on a proxy that has been revoked, 在线上state.selected = [];
我是这个东西的新手,如何在延迟后访问状态?我必须异步执行吗?如果是这样,怎么办?
我正在尝试在 Windows 上使用aioquic,但在初始时出现此错误pip install -e .:
src/aioquic/_crypto.c(4): fatal error C1083: Non \xc5\xa0 possibile aprire il file inclusione: \'openssl/err.h\': No such file or directory\n error: command \'C:\\\\Program Files (x86)\\\\Microsoft Visual Studio\\\\2019\\\\BuildTools\\\\VC\\\\Tools\\\\MSVC\\\\14.26.28801\\\\bin\\\\HostX86\\\\x86\\\\cl.exe\' failed with exit status 2\nRun Code Online (Sandbox Code Playgroud)\n我通过 Chocolatey 安装了 openssl,但该文件似乎丢失了。有任何想法吗?
\n我找不到有关此事的任何文档,是否有类似于CollapsingToolbarCompose 中的内容?
我发现的只是这里提到了它,但没有关于如何设置它
我编写了一个 Next.js 应用程序,即将部署。我想知道在保持 SSR 的同时复制到服务器上部署的严格必要的文件是什么(不是使用 静态生成的next export):
.next/文件夹?