这是 Vugu 文档中显示的示例,但它似乎不起作用。 https://www.vugu.org/doc/dom-events
不会调用 Toggle 函数。
</head>
<body>
<div id="root">
<div>
<div vg-if='c.Show'>I am here!</div>
<button @click='c.Toggle()'>Toggle me Silly</button>
</div>
<components:Header></components:Header>
<vg-comp expr="c.Body"></vg-comp>
<components:Footer></components:Footer>
</div>
</body>
</html>
<script type="application/x-go">
import "github.com/vugu/vgrouter"
import "log"
type Root struct {
vgrouter.NavigatorRef
Body vugu.Builder // main body content
AutoReload bool // set to true during dev
Show bool `vugu:"data"`
}
func (c *Root) Init(ctx vugu.InitCtx) {
log.Println(c.AutoReload)
log.Println(c.Show)
}
func (c *Root) Toggle() {
c.Show = !c.Show
log.Println(c.Show)
}
</script>
冉冉说
相关分类