网址:Dash与下划线 [英] URLs: Dash vs. Underscore

查看:155
本文介绍了网址:Dash与下划线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

应该是/about_us 还是/about-us ?

从可用性的角度来看,我个人认为/about-us 对于最终用户而言要好得多,而Google和大多数其他网站(和javascript框架)则使用下划线命名模式.这只是风格问题吗?破折号是否存在兼容性问题?

From usability point of view, I personally think /about-us is much better for end-user yet Google and most other websites (and javascript frameworks) use underscore naming pattern. Is it just matter of style? Are there any compatibility issues with dashes?

推荐答案

这只是一个猜测,但似乎他们选择了人们最有可能不会使用的名称.这样,您可以使用包含连字符的名称,并且仍将下划线用作单词定界符,例如可以将UseTwo-wayLinks转换为use_two-way_links.

This is just a guess, but it seems they picked the one that people most probably wouldn't use in a name. This way you can have a name that includes a hyphenated word, and still use the underbar as a word delimiter, e.g. UseTwo-wayLinks could be converted to use_two-way_links.

在您的示例中,/about-us将是一个名为连字词"about-us"的目录(如果存在这样的单词,而/about_us将是一个名为两个单词的短语"about us"的目录,该短语将转换为一串非白色字符.

In your example, /about-us would be a directory named the hyphenated word "about-us" (if such a word existed, and /about_us would be a directory named the two-word phrase "about us" converted to a single string of non-white characters.

这篇关于网址:Dash与下划线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆