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

设想

通过pure-go编写页面, 似乎不太好实现, 就当学习前端html基础了。

完成度 0.5%

App.go:

go 复制代码
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,
				},
			}},
		},
	}
}

wgo

编写一个wgo。

wgo run 等价于 yarn serve, 开发模式的页面,加载html到内存

wgo build 等价于yarn build, 构建html到dist/目录下。

相关推荐
devilnumber5 小时前
Java 递归算法 详解 + 核心要点 + 实战运用 + 避坑指南
java·开发语言·算法
独泪了无痕6 小时前
MyBatis魔法堂:结果集映射
后端·mybatis
copyer_xyf6 小时前
LangChain 调用 LLM
后端·python·agent
copyer_xyf6 小时前
Prompt 组织管理
后端·python·agent
asdfg12589637 小时前
JavaBean是什么?怎么理解?有什么用途?
java·开发语言
dsyyyyy11017 小时前
JavaScript变量
开发语言·javascript·ecmascript
z落落8 小时前
C#WinForm 窗体切换与窗体传值(登录跳转案例)+WinForm 窗体传值(从上往下传、从下往上传)
开发语言·windows·c#
allway28 小时前
How to Echo Multiline to a File in Bash [3 Methods]
开发语言·chrome·bash
weixin_462446238 小时前
手把手教你用 Bash 脚本自动更新 /etc/hosts —— 自动绑定网卡 IP 与节点名
开发语言·tcp/ip·bash
一个梦醒了8 小时前
安装git bash选项推荐
开发语言·git·bash