html/css/js文件该如何命名才更规范?
有两个英文单词拼接的该怎么命名html/css/js文件?
比如smarthome。
用smartHome.html(驼峰)还是smarthome.html(全小写)还是smart-home.html(破折号连接)?
我知道没有强制命名方式,我是想知道哪种命名方式更规范。
html/css/js文件该如何命名才更规范?
有两个英文单词拼接的该怎么命名html/css/js文件?
比如smarthome。
用smartHome.html(驼峰)还是smarthome.html(全小写)还是smart-home.html(破折号连接)?
我知道没有强制命名方式,我是想知道哪种命名方式更规范。
一般大写开头大多数是MS系列的,小写大多数是liunx系列。
如果扯淡文件这些,并不是什么优势。
举个例子
UserList.html --大驼峰
userList.html --首字母小写驼峰式
userlist.html --全小写
user-list.html --符号隔开
我们加上域名看看
http://baidu.com/UserList.html
http://baidu.com/userList.html
http://baidu.com/userlist.html
http://baidu.com/user-list.html
另外一个例子
UserDetailedReport.html
http://baidu.com/UserDetailedReport.html
userDetailedReport.html
http://baidu.com/userDetailedReport.html
userdetailedreport.html
http://baidu.com/userdetailedreport.html
user-detailed-report.html
http://baidu.com/user-detailed-report.html
其实当单词多的时候。你会发现 优势比较明显的就是驼峰式。而很多人喜欢用 -,尤其是大驼峰式开头的更注重让对人注意力更明显。
我一直也纠结这个。到底是大写开头还是全小写,或者其它。
其实这个很多的时候看公司命名规定。
如果按我个人其实更喜欢 大驼峰式命名开始,因为更注重于易读性。便于团队维护,主要是文件夹跟html文件名。
而对于 css js 则小写
css = .btn-default =多个单词
命名主要是给予团队更容易 易读。那种一看就能猜出大概意思的 是最好的
10 回答11.1k 阅读
6 回答3k 阅读
5 回答4.8k 阅读✓ 已解决
4 回答3.1k 阅读✓ 已解决
2 回答2.6k 阅读✓ 已解决
3 回答5.1k 阅读✓ 已解决
5 回答1.9k 阅读
更多请看这篇文章
以及为什么文件名不能大写
另外,这个问题没有什么好的答案。请根据公司的规范来。