我正在尝试将旧的 React router dom 代码迁移到 v6,我想知道如何监听路由更改,我现在正在使用useHistory
const history = useHistory()
//then
history.listen(...)
Run Code Online (Sandbox Code Playgroud)
我确实阅读了新文档,并且发现它useHistory
已更改为useNavigate
const navigate = useNavigate()
//then
navigate.listen(...) // listen is not a function
Run Code Online (Sandbox Code Playgroud)
你能帮我找到一种方法来监听 v6 中的路由变化吗
// This is a React Router v6 app
import { useNavigate } from "react-router-dom";
function App() {
let navigate = useNavigate();
function handleClick() {
navigate("/home");
}
return (
<div>
<button onClick={handleClick}>go home</button>
</div>
);
}
Run Code Online (Sandbox Code Playgroud) 我正在使用Chakra UI 库提供的“暗模式”功能。但是,我不知道如何更改“暗模式”颜色。在文档中,我看到 Chakra UI 基于一种叫做“ styled-system ”的东西,所以我试图传递一个新的东西:theme
themeProvider
const theme = {
...defaultTheme,
modes: {
dark: {
background: '#000',
},
},
};
Run Code Online (Sandbox Code Playgroud)
<ThemeProvider theme={theme}></ThemeProvider>
Run Code Online (Sandbox Code Playgroud)
然而,这没有用。我也试图modes
用一个colors
对象包裹这个对象,但这也不起作用。如何自定义“暗模式”颜色?
大家好,当我尝试在 ubuntu 22 虚拟机中构建 docker 映像时,我遇到了奇怪的问题
[+] Building 10.6s (5/14)
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 864B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/kong/kong:2.7.0 0.0s
=> CACHED [ 1/12] FROM docker.io/kong/kong:2.7.0 0.0s
=> ERROR [ 2/12] RUN apk update && apk add git unzip luarocks 10.5s
------
> [ 2/12] RUN apk update && apk add git unzip luarocks:
#0 0.240 fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/main/x86_64/APKINDEX.tar.gz …
Run Code Online (Sandbox Code Playgroud) 当用户仅使用 vanilla javascript 选择“笔记本电脑”时,我想隐藏下面的 div
<select class="form-control input-lg" name="category">
<option value="Desktop PCs & Central unit">Desktop PCs & Central unit</option>
<option value="Laptop">Laptop</option>
</select>
<div class="form-group">
<label class="" for="Name">Name</label>
<input type="text"/>
</div>
Run Code Online (Sandbox Code Playgroud)