SCXML 可执行内容 if、 else、 else if

2021-01-29  本文已影响0人  寻找无名的特质

<if> 是条件执行元素的容器,属性是条件cond,子元素可以是<else>和<else if>。这些元素很好理解,与一般的控制语句一样,elseif可以有多个,else需要在所有的elseif后出现,最后是</if>结束符。这些元素可以嵌套,下面是一个简单的例子:

<if cond="cond1">
  <!-- selected when "cond1" is true -->
<elseif cond="cond2"/>
  <!-- selected when "cond1" is false and "cond2" is true -->
<elseif cond="cond3"/>
  <!-- selected when "cond1" and "cond2" are false and "cond3" is true -->
<else/>
  <!-- selected when "cond1", "cond2", and "cond3" are false -->
</if>

很直观也很简单。

上一篇 下一篇

猜你喜欢

热点阅读