【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/目录下。

相关推荐
栈与堆16 小时前
LeetCode-1-两数之和
java·数据结构·后端·python·算法·leetcode·rust
superman超哥17 小时前
双端迭代器(DoubleEndedIterator):Rust双向遍历的优雅实现
开发语言·后端·rust·双端迭代器·rust双向遍历
1二山似17 小时前
crmeb多商户启动swoole时报‘加密文件丢失’
后端·swoole
马卡巴卡17 小时前
Java CompletableFuture 接口与原理详解
后端
Jayden_Ruan17 小时前
C++蛇形方阵
开发语言·c++·算法
神奇小汤圆17 小时前
Java线程协作工具:CountDownLatch 、CyclicBarrier、Phaser、Semaphore 、Exchanger
后端
gelald17 小时前
ReentrantLock 学习笔记
java·后端
心.c17 小时前
如何基于 RAG 技术,搭建一个专属的智能 Agent 平台
开发语言·前端·vue.js
计算机学姐17 小时前
基于SpringBoot的校园资源共享系统【个性化推荐算法+数据可视化统计】
java·vue.js·spring boot·后端·mysql·spring·信息可视化
智航GIS17 小时前
10.7 pyspider 库入门
开发语言·前端·python