我设置了路线:
<Route path="/search/:name" component={foo} />
在我尝试根据输入的名称重定向的组件中:
<Redirect to="/search" />
我想将this.state.name
传递给重定向,例如/search/name
。怎么样?
答案 0 :(得分:5)
解决:
我不得不用大括号括起来:
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="jquery.scrollify.js"></script>
<style>
.sectioncolor {
background-color: black;
}
</style>
<script>
$(function() {
$.scrollify({
section : ".section-class-name",
sectionName : "section-name",
before:function(index, sections) {
var sno = index+1;
$(".section-class-name").removeClass("sectioncolor");
$(".section-class-name:nth-child("+sno+")").addClass("sectioncolor");
},
after:function(index, sections) {
var sno = index+1;
$(".section-class-name").removeClass("sectioncolor");
$(".section-class-name:nth-child("+sno+")").addClass("sectioncolor");
},
});
});
</script>
</head>
<body>
<div class="section-class-name" data-section-name="home" style="height:500px;border:1px solid red;"></div>
<div class="section-class-name" data-section-name="about" style="height:500px;border:1px solid black;"></div>
</body>
</html>
(感谢Giri的指导)