Code Monkey home page Code Monkey logo

Comments (10)

otakustay avatar otakustay commented on August 24, 2024

规范均是由公司不同组的代表同学讨论投票得出的,在制定过程中对于使用2空格还是4空格也有过讨论,最后由投票决定。缩进方面我们没有修改的计划

from spec.

superwoods avatar superwoods commented on August 24, 2024

html的4空格缩进会导致增量问题是不存在的,因为生产模式的时候,html会被自动删除冗余的空格缩进,所以开发模式显然是4空格是国际惯例

from spec.

errorrik avatar errorrik commented on August 24, 2024

另外一个理由是,很多同学其实会使用一个editor写各种代码。虽然一些editor能做到不同代码配不同的缩进,但是通常大家不会这么干。在其它语言都规定是4空格缩进时,html也应如此。

如果你的产品很在意这些空格,在上到线上环境时,你会使用工具干掉它们。或者,其实你并不太在意。

from spec.

oathsign avatar oathsign commented on August 24, 2024

正如errorrik所说,线上环境,我会使用工具干掉他们。所以,我并不在意是4个空格帅还是2个空格更严谨。但是这个问题真的困扰了我很长时间,我想过,问过,也研究过。有很多人觉得这种事自己随意来就好了嘛,别人怎么做你也跟着做就好了嘛。但我真的需要一个理由..........谢谢你的建议,综合几位的讨论,我觉得4空格的建议可以说服我。其他语言也是4空格,没必要单独给html开小灶,O(∩_∩)O哈哈~。问题可以关闭了。

from spec.

hax avatar hax commented on August 24, 2024

@superwoods 缩进不存在国际惯例。我公司都用tab。

from spec.

flyer153 avatar flyer153 commented on August 24, 2024

在编写可维护的js中也有提到过推荐使用4个空格字符为一个缩进层级。html虽然是标记语言,但为了自己编码视觉统一,也不应例外。

from spec.

oathsign avatar oathsign commented on August 24, 2024

用tab应该是有问题的,IDE和各系统规定的tab宽度千差万别。虽然4空格,2空格会存在一定的争议。但是用tab是不推荐的。排版会有很大区别。

from spec.

otakustay avatar otakustay commented on August 24, 2024

这个问题有必要继续讨论吗,或者换一个更合适的地方讨论?

无论是4空格、2空格、TAB,甚至3空格、5空格都是合理的,缩进永远不存在所谓公认规则也不存在正确与否

from spec.

hax avatar hax commented on August 24, 2024

@MisakaMikotoMM tab并没有什么问题。我会在12月26日webrebuild上海的分享上讨论这个经典问题,欢迎前来讨论。
@otakustay 合理是相对的。是不是“永远”不好说(因为现有历史不够长)。目前现状是只能一点点纠正偏见。

from spec.

errorrik avatar errorrik commented on August 24, 2024

关于缩进,我还是觉得无论4空格还是tab都是合理的,哪个团队有什么样的文化和要求,就用哪种吧。

但是,主观的说,我始终觉得2空格挺2的,而且随着语言特性越来越便利(如 promise、async、pipeline operator ),2空格只剩下锻炼斗鸡眼的作用了

from spec.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.