> ## 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:set

> 使用 arc:set 關鍵字在 ArcScript 中為屬性設定值。

export const siteNameShort = "知行之橋";

`arc:set` 關鍵字可以為屬性設定值。如果在不存在的物件中設定屬性，則會自動建立該物件。

使用 `arc:set` 設定值有兩種方法。可以設定 **value** 參數；對於多行且複雜的大值，也可以使用關鍵字本身的範圍來設定值。

## 參數

* **item**：指定要在其中設定屬性的物件。如果未指定物件，則使用預設物件。
* **attr**：屬性名稱。也可以使用點號表示法指定物件（例如 `item.prefix:attr`）。
  * 完整的屬性名稱包含字首和屬性名，但字首不是必需的。
  * 屬性也可以使用井號（`#`）表示為陣列。這意味著陣列可以包含多個值，其中每個值都可以使用從 1 開始的索引來引用。例如，`attr="myitem.myattribute#2"` 引用 `myattribute` 屬性中的第二個值。
* **value**：要分配給屬性的值。如果未提供此參數，則使用 `arc:set` 關鍵字的整個主體作為值。這對於設定長值或多行值很方便。
* **copyfrom**：將此參數中指定物件的屬性複製到 **item** 參數指定的物件中。

## 控制屬性

無

## 範例

使用關鍵字範圍為名為 `input` 的物件的 message 屬性設定值：

```xml theme={null}
<arc:set item="input" attr="message">
  Dear [name],
  You have won a cruise trip to Hawaii.
  Please confirm your acceptance by [date].
  Thanks, [sales]
</arc:set>
```

## 另請參閱

* [arc:unset](./op-arc-unset)：從物件中移除屬性。
* [arc:setm](./op-arc-set-m)：使用單個關鍵字設定多個屬性。
