2
0

test.html 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Juris 测试页面</title>
  6. <script src="https://unpkg.com/juris"></script>
  7. <style>
  8. body { font-family: Arial, sans-serif; padding: 20px; }
  9. .card { border: 1px solid #ccc; padding: 20px; margin: 10px; border-radius: 5px; }
  10. .button { background: #007bff; color: white; padding: 10px 15px; border: none; border-radius: 4px; cursor: pointer; }
  11. </style>
  12. </head>
  13. <body>
  14. <h1>Juris 框架简单测试</h1>
  15. <div id="app"></div>
  16. <script>
  17. // 创建一个简单的Juris应用
  18. const app = new Juris({
  19. states: {
  20. count: 0,
  21. message: "Hello Juris!"
  22. },
  23. layout: {
  24. tag: "div",
  25. children: [
  26. {
  27. tag: "div",
  28. class: "card",
  29. children: [
  30. { tag: "h2", text: "计数器测试" },
  31. { tag: "p", text: () => `当前计数: ${app.getState("count")}` },
  32. {
  33. tag: "button",
  34. class: "button",
  35. text: "增加计数",
  36. onclick: () => app.setState("count", app.getState("count") + 1)
  37. }
  38. ]
  39. },
  40. {
  41. tag: "div",
  42. class: "card",
  43. children: [
  44. { tag: "h2", text: "消息测试" },
  45. { tag: "p", text: () => app.getState("message") },
  46. {
  47. tag: "input",
  48. type: "text",
  49. placeholder: "输入新消息",
  50. oninput: (e) => app.setState("message", e.target.value)
  51. }
  52. ]
  53. },
  54. {
  55. tag: "div",
  56. class: "card",
  57. children: [
  58. { tag: "h2", text: "简单表格测试" },
  59. {
  60. tag: "table",
  61. children: [
  62. {
  63. tag: "thead",
  64. children: [
  65. {
  66. tag: "tr",
  67. children: [
  68. { tag: "th", text: "姓名" },
  69. { tag: "th", text: "年龄" }
  70. ]
  71. }
  72. ]
  73. },
  74. {
  75. tag: "tbody",
  76. children: [
  77. {
  78. tag: "tr",
  79. children: [
  80. { tag: "td", text: "张三" },
  81. { tag: "td", text: "25" }
  82. ]
  83. },
  84. {
  85. tag: "tr",
  86. children: [
  87. { tag: "td", text: "李四" },
  88. { tag: "td", text: "30" }
  89. ]
  90. }
  91. ]
  92. }
  93. ]
  94. }
  95. ]
  96. }
  97. ]
  98. }
  99. });
  100. // 渲染应用
  101. app.render('#app');
  102. </script>
  103. </body>
  104. </html>