Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 反应路由器:为什么可以';不能在URL中放置hastag(#)?_Javascript_Reactjs_React Router_Url Routing - Fatal编程技术网

Javascript 反应路由器:为什么可以';不能在URL中放置hastag(#)?

Javascript 反应路由器:为什么可以';不能在URL中放置hastag(#)?,javascript,reactjs,react-router,url-routing,Javascript,Reactjs,React Router,Url Routing,React路由器:1.0.0 我正在使用哈希历史记录,我正在考虑使用哈希标记作为URL中路径的一部分(而不是作为片段),但是任何具有哈希标记的路径都会在使用哈希时立即被切断 例如: this.props.history.pushState(null, `/blah/blah/#blah`); 路线: /#/blah/blah/?\u k=pdcm9b this.props.history.pushState(null, `/blah/#blah/blah`); this.props.hist

React路由器:1.0.0

我正在使用哈希历史记录,我正在考虑使用哈希标记作为URL中路径的一部分(而不是作为片段),但是任何具有哈希标记的路径都会在使用哈希时立即被切断

例如:

this.props.history.pushState(null, `/blah/blah/#blah`);
路线: /#/blah/blah/?\u k=pdcm9b

this.props.history.pushState(null, `/blah/#blah/blah`);
this.props.history.pushState(null, `/#blah/blah/blah`);
路线: /#/blah/?\u k=pdcm9b

this.props.history.pushState(null, `/blah/#blah/blah`);
this.props.history.pushState(null, `/#blah/blah/blah`);
路线: /#/?k=pdcm9b

this.props.history.pushState(null, `/blah/#blah/blah`);
this.props.history.pushState(null, `/#blah/blah/blah`);
问题:
为什么会发生这种情况?我可以在URL中使用hashtags吗(例如,即使我需要切换到createBrowserHistory)?

当然可以,但必须使用URI编码的表单
%23
。服务器环境是否接受路径中的
#
是另一回事entirely@PaulS. 我一直在网上搜索,但是我找不到一个好的例子来逃脱Javascript中的#,因为我尝试了这个.props.history.pushState(null,
/blah/%23/blah
),创建的URL没有逃脱。当然可以,但必须使用URI编码的表单
%23
。服务器环境是否接受路径中的
#
是另一回事entirely@PaulS. 我一直在网上搜索,但是我找不到一个好的例子来逃脱Javascript中的#,因为我尝试了这个.props.history.pushState(null,
/blah/%23/blah
),并且创建的URL没有逃脱。