我有一个关于在活动页面上设置锚组件样式的问题。
这是我的代码:
import Link from 'next/link';
import styled from 'styled-components';
const NavStyle = styled.nav`
display: flex;
justify-content: space-between;
.nav-link a {
text-decoration: none;
color: white;
padding: 10px;
background-color: #FFCF00;
}
`;
export default function Nav() {
return (
<NavStyle>
<div className="nav-link">
<Link href="/" passHref>
<a>HOME</a>
</Link>
<Link href="/pricing">
<a>PRICING</a>
</Link>
<Link href="/terms">
<a>TERMS</a>
</Link>
<Link href="/login">
<a>LOGIN</a>
</Link>
</div>
<Link href="/">
<a>LOGO</a>
</Link>
</NavStyle>
)
}
Run Code Online (Sandbox Code Playgroud)
我想要的是,当我单击链接并移动到另一个页面时,活动链接(与 URL 匹配)将具有绿色背景。我已经尝试过这个,但它没有任何改变:
const NavStyle = styled.nav`
display: flex;
justify-content: space-between;
.nav-link a { …Run Code Online (Sandbox Code Playgroud) 我有一个接收一些参数的函数,但是当我尝试使用该参数时,它会抛出错误。
// 功能
pub fn solc_compile(compiler: &str, file: &str, out: &str, config: templates::Config) {
let mut args = vec![
"--bin",
"--abi",
"--include-path",
"./libs",
"--include-path",
"./node_modules",
"--output-dir",
out,
];
if config.compiler.optimize {
let runs: &str = config.compiler.runs.to_string().as_str();
args.push("--optimize");
args.push("--optimize-runs");
args.push(runs);
}
}
Run Code Online (Sandbox Code Playgroud)
// 在函数参数上使用的配置类型(config templates::Config)。
模板.rs
// config templates.
#[derive(Deserialize, Serialize)]
pub struct Config {
pub info: ConfigInfo,
pub compiler: ConfigCompiler,
}
// config.info templates.
#[derive(Deserialize, Serialize)]
pub struct ConfigInfo {
pub name: String,
pub license: String,
}
// config.compiler templates. …Run Code Online (Sandbox Code Playgroud)