这听起来可能有些转储,但是我应该如何从React JS中的URL读取URL并获取其值。 我被告知要使用QueryString来处理GET参数。
网址看起来具有以下结构:
<section id="section-one">
<ul class="categories">
<li><a href="#">HEADPHONES</a></li>
<li><a href="#">EARPHONES</a></li>
<li><a href="#">BLUETOOTH</a></li>
<li><a href="#">WATERPROOF</a></li>
<li><a href="#">SPORTS</a></li>
<li><a href="#">METALLIC</a></li>
<li><a href="#">WOODEN/BAMBOO</a></li>
<li><a href="#">EARMUFF</a></li>
</ul>
<div class="slideshow-container">
<div class="mySlides">
<p class="description"></p>
<div class="img">
<img
src="https://i.pinimg.com/originals/5a/e5/8f/5ae58f5036997cfd4636917403c3c951.jpg"
alt="image1"
style="width:100%"
/>
</div>
<a href="#">WIEW MORE</a>
</div>
<div class="mySlides">
<p class="description"></p>
<div class="img">
<img
src="https://images.unsplash.com/photo-1500382017468-9049fed747ef?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&w=1000&q=80"
alt="image2"
style="width:100%"
/>
</div>
<a href="#">WIEW MORE</a>
</div>
<div class="mySlides">
<p class="description"></p>
<div class="img">
<img
src="https://cdn.pixabay.com/photo/2017/02/22/20/02/landscape-2090495_960_720.jpg"
alt="image3"
style="width:100%"
/>
</div>
<a href="#">WIEW MORE</a>
</div>
<a class="prev" onclick="plusSlides(-1)"></a>
<a class="next" onclick="plusSlides(1)"></a>
</div>
</section>
在组件类中,我使用以下代码:
sub test()
Dim arrAccSof As Variant
arrAccSof = .Range(.Cells(3, 1), .Cells(MaxRowAccSof, 4))
For j = LBound(arrAccSof) To UBound(arrAccSof)
If IsEmpty(arrAccSof(j, 3)) Then
arrAccSof(j, 3).Value = 0
End If
If IsEmpty(arrAccSof(j, 4)) Then
arrAccSof(j, 4).Value = 0
End If
Next j
end sub
为什么问号标记也已被检索? 以及如何解决它,这样我就可以在不花太多钱的情况下获得这些价值?
答案 0 :(得分:2)
URLSearchParams
:const windowUrl = window.location.search;
const params = new URLSearchParams(windowUrl);
// params['id']
react-router
解决方案,则可以看到this answer。答案 1 :(得分:0)
如果您使用的是react-router
,这很容易。看到这个:https://tylermcginnis.com/react-router-query-strings/