ClassName

amis 中大部分的组件都支持配置 className 和 xxxClassName,他可以用来配置组件 dom 上的 css 类名,可以结合帮助类 css 来定制一些样式。具体帮助类 css 请前往这里

配置方式有两种:

  1. 直接配置字符串如:className: "text-danger" 文字标红。
  2. 采用对象配置,这个用法主要是方便写表达式如:className: {"text-danger": "this.status == 1"} 表示当数据 status 状态是 1 时,文字飘红。
  1. {
  2. "type": "page",
  3. "title": "引用",
  4. "body": [
  5. {
  6. "type": "form",
  7. "actions": [],
  8. "debug": true,
  9. "mode": "horizontal",
  10. "body": [
  11. {
  12. "type": "radios",
  13. "name": "status",
  14. "value": "1",
  15. "label": "状态",
  16. "options": {
  17. "1": "离线",
  18. "2": "在线"
  19. }
  20. },
  21. {
  22. "type": "mapping",
  23. "name": "status",
  24. "label": "状态展示",
  25. "map": {
  26. "1": "离线",
  27. "2": "在线"
  28. },
  29. "className": {
  30. "text-muted": "this.status == '1'",
  31. "text-success": "this.status == '2'"
  32. }
  33. }
  34. ]
  35. }
  36. ]
  37. }