> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kasoftware.com/llms.txt
> Use this file to discover all available pages before exploring further.

# arc:equals

> 将属性值与参考值进行比较，匹配时执行正文块；如果属性不存在则抛出异常。

arc:equals 关键字可以将属性的值与一个参考值进行比较。和 [arc:check](https://docs.kasoftware.com/26.4/self-hosted/zh/scripting/keyword-reference/op-arc-check.md) 不同，arc:equals 关键字将会在指定的对象没有包含指定的属性时抛出异常。如果指定的属性存在且值也匹配，那么比较就是成功的。

> [!NOTE]
>
> `arc:equals` 和 [arc:check](https://docs.kasoftware.com/26.4/self-hosted/zh/scripting/keyword-reference/op-arc-check.md) 都需要属性的名称，该属性的值将会与给定的值进行比较。如果需要比较两个值，可以使用 [arc:select](https://docs.kasoftware.com/26.4/self-hosted/zh/scripting/keyword-reference/op-arc-select.md)。例如：
>
> ```xml theme={null}
> <arc:select value="[company_name]">
>   <arc:case value="CompanyA">
>     <img src="http://www.companya.com/favicon.ico" />
>   </arc:case>
>   <arc:case value="CompanyB">
>     <img src="http://www.companyb.com/favicon.ico" />
>   </arc:case>
>   <arc:default>
>     <img src="http://www.myhosting.com/generic.ico"/>
>   </arc:default>
> </arc:select>
> ```

## 参数

* **item**：用于比较属性的对象。指定对象不是必需的。如果未指定对象，则使用默认输出对象。
* **attr**：要比较的属性的名称。
* **case**：比较时是否忽略大小写。默认为大小写敏感；要忽略大小写，将 case 参数设为 “ignore”。
* **value**：与属性比较的值。
* **action**：如果相等将执行的操作。允许的值有：break，continue。

## 控制属性

无

## 示例

和其它条件的关键字一样，arc:equals 关键字主体也可以也包含 [arc:else](https://docs.kasoftware.com/26.4/self-hosted/zh/scripting/keyword-reference/op-arc-else.md) 关键字，如果值不匹配时将会执行 else 代码块。下面的示例列出了除了 .err 文件之外的所有文件：

```xml theme={null}
<arc:call op="fileListDir">
  <arc:equals attr="file:extension" value=".err">
  <arc:else>
    <arc:push/>
  </arc:else>
  </arc:equals>
</arc:call>
```

## 另请参阅

* [arc:select](https://docs.kasoftware.com/26.4/self-hosted/zh/scripting/keyword-reference/op-arc-select.md)：在多个情况中选择。
* [arc:notequals](https://docs.kasoftware.com/26.4/self-hosted/zh/scripting/keyword-reference/op-arc-not-equals.md)：创建一个不满足相等条件时执行的代码块。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.