加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angularjs directive和component命名规则的坑

发布时间:2020-12-17 09:53:59 所属栏目:安全 来源:网络整理
导读:angularjs directive和component命名规则的坑 今天才发现angularjs doc中directive有这么一段 Normalization Angular normalizes an element's tag and attribute name to determine which elements match which directives. We typically refer to directiv

angularjs directive和component命名规则的坑

今天才发现angularjs doc中directive有这么一段

Normalization Angular normalizes an element's tag and attribute name
to determine which elements match which directives. We typically refer
to directives by their case-sensitive camelCase normalized name (e.g.
ngModel). However,since HTML is case-insensitive,we refer to
directives in the DOM by lower-case forms,typically using
dash-delimited attributes on DOM elements (e.g. ng-model).

The normalization process is as follows:

Strip x- and data- from the front of the element/attributes. Convert
the :,-,or _-delimited name to camelCase.

这段其实也讲了html命名转化规则

比如我定义一个component名字为cpuLoad,在模板引用中,我们需要这样引用<cpu-load>。就是将首字母小写,每个名字部分首字母大写的形式转化为通过-来连接小写部分的形式。

命名的时候得注意这个隐含的转化规则,真是个坑

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读