创建计算多种化学品总质量的网页
创建一个两栏多行的 FormFunction, 一栏为化学品,另一栏为摩尔数. 你可以用 RepeatingElement 和 CompoundElement 实现这一点.
In[1]:=
![Click for copyable input](assets.zh/create-a-webpage-that-computes-the-total-mass-of-m/In_10.png)
CloudDeploy[
FormFunction[
{"items", None} ->
RepeatingElement[
CompoundElement[<|
"chemical" -> <|
"Label" -> "Chemical",
"Interpreter" -> "Chemical"
|>,
"mol" -> <|
"Label" -> "Molar amount",
"Interpreter" -> QuantityVariable["Amount"]
|>
|>]],
EntityGroup[EntityInstance @@@ #items]["AbsoluteMass"] &
]
]
访问该表单.
![](assets.zh/index.zh/GB_15.png)
你可以任意添加行数,表单将计算总质量.
![](assets.zh/index.zh/GB_16.png)
得益于响应式设计,该表单在屏幕有限的移动设备上看起来也很美观.
![](assets.zh/index.zh/GB_17.png)