首页 文章

在离子2中,指令,属性和属性之间的真正区别是什么?

提问于
浏览
2

因此,标准html属性是左侧属性名称和右侧引号值的属性 . (class =“buttons”)要更改Ionic中元素的内容,语法只是值名称,没有引号 . 但是我注意到有时候这个值被称为指令,有时候是属性,有时候是属性 . 有什么不同?

以下是来自文档的示例:

按钮使用标准元素,但使用离子按钮 directive 进行增强 .

<button ion-button>Button</button>

颜色 property 设置按钮的颜色 . Ionic包含许多可以轻松覆盖的默认颜色:

<button ion-button **color="light"** >Light</button>

//我认为属性在这里被称为属性 .

要使用按钮的轮廓样式,只需添加大纲 property

<button ion-button color="light" **outline** >Light Outline</button>  //outline is called a property as well.

添加大 attribute 以使按钮变大或小以使其变小:

<button ion-button **large** >Large</button>

//这里称为large属性 . 为什么不把它称为 property 或指令?

它有没有区别或没有?

1 回答

  • 0

    Button是Ionic主要由Angular组成的一个组件 . 所以简而言之:

    • ion-button 是一个构建在 [ion-button] 选择器上的组件,您可以在source找到它 .

    • coloroutlinelargeion-button 组件的输入,您也可以在source中看到

    从DOM的角度来看,所有这些都是属性 . 虽然如果你真的需要一个完全由Angular编译的 [attribute] ,你必须使用 [attr.attribute] 绑定,这对于指令/组件及其输入是不一样的 . 输入是指令/组件的属性 .

相关问题