4.4 HTML Comments 4.4 HTML注释

You can leave comments in .html and .liquid files, and in the Shopify Custom Liquid blocks and Sections.

我们可以在.html、 .liquid文件以及shopify自定义区块和模块里面使用注释。

The opening comment tag is <!-- and the closing tag is -->.

注释标签的开始标签和结束标签分别是<!– 和 –>。

Comments are useful for two main reasons:

注释有两个方面的作用:

  1. Explaining your code to your future self or other developers. E.g:<!-- The below code is temporary, for the christmas sale -->

    对代码的解释:让我们自己开的懂也可以让其它开发者看的懂。

    例如:<!– The below code is temporary, for the christmas sale –>

  2. “Commenting out” blocks of code when you don’t want to delete them, but you want to disable or hide them temporarily. You will hear developers using the phrase “comment out” a lot, to mean temporarily disabling some code for debugging reasons.

    注释掉代码块:有些代码我们不想删掉但是想暂时隐藏或者让它们失去效力,我们就可以注释掉这一块代码。

如上图所示,我们就是注释掉了christmas-note这个Div里面的内容。

上一篇 4.2 Non-semantic Elements: <div> and<span> 无语义元素:<div>和<span>
下一篇 4.3 Default appearances 4.3默认样式
AeroCore图片
AeroCore图片
AeroCore图片
AeroCore图片
AeroCore图片
最新评论
暂无评论