跳到主要内容

ARC 2.0.0-beta.25

节点、值与 sugar

用可读的 node sugar 表达作者意图,同时知道它会编译成哪种语义 AUP node。

DSL node sugar 让编写简洁,但不会创建一套不同的 renderer contract。compiler 会把常见形式降为语义 AUP node:

DSL 形式编译为
stackrowgridcardview
h1h2h3pbadgetext
buttontabaction
repeatafs-list

内联 literal 会变成 text.contentaction.labelkey=value 提供属性。值可以是 string、number、boolean、null、object 或 array。DSL 有 compile-time 的 +* 操作和 macro substitution;它不是通用 JavaScript expression language。

data、visibility 与 event

aup
button rename "Rename" primary ->
  set headline props {content: "Renamed"}

button load "Load" primary ->
  set list src "/modules/index"

from 设置 srcshow if 设置 visibleon <event> -> ... 能绑定明确名称的 event。裸 -> 只用于 action/button 的 click shorthand。

show if 是呈现控制,不是 authorization。tree 被隐藏不代表 AFS access policy 已经生效。

另一个 node 要引用 ID 时应明确写出

作者不写时 compiler 可以推断稳定 ID。但 event target、patch、test anchor 或其他 node 必须命名目标时,应给它显式 ID。这会让 source 更容易 review,也避免 refactor 时意外改变身份。

-> page 会降为当前 root update { target: "_root", set: { page } };新 source 应使用 DSL 形式,不要手写 legacy top-level page field。

runtime 语义字段见 节点、事件与消息;compile-time component 与 loop 见 组件、循环与 i18n