【go】仅设想,能不能通过pure go编写页面。

时间:2024-10-23 07:21:02
package src import ( d "github.com/go-webtools/wgo/core/document" "github.com/go-webtools/wgo/core/react" "github.com/go-webtools/wgo/core/window" ) func App() d.Html { state, setState := react.UseState("Hello") handleClick := func() { window.Alert("Clicked") setState("world") } return d.Html{ Child: []d.Element{ d.H1{Child: "Hello World"}, // 添加一个 H1 元素 d.Div{Child: []d.Child{ "Nested Child And State is:", // 字符串作为子元素 state, d.H1{Child: "Nested H1"}, // 嵌套一个 H1 d.Button{ Child: "按钮", OnClick: handleClick, }, }}, }, } }