简体   繁体   English

在page.js中编码URL

[英]Encode URL in page.js

Is there a way to encode a URL by default while using page.js 有没有一种方法可以在使用page.js时默认对URL进行编码

For example: 例如:

<a href="/some link">Click</a

This gives http://example.com/some link in the address bar instead of http://example.com/some%20link . 这会在地址栏中提供http://example.com/some link ,而不是http://example.com/some%20link

To achieve this you need to do 为此,您需要做

<a href={encodeURI('/some link')}>click</a>

Is there any other work around? 周围还有其他工作吗?

I think you will need to mention the url in this form: 我认为您需要以这种形式提及网址:

<a href="some_link">Click</a>

Which will mean http://example.com/some_link 这意味着http://example.com/some_link

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM