-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.nue
57 lines (44 loc) · 1.35 KB
/
app.nue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<!-- MVC Controller -->
<script>
// import application router
import { router } from '/nuejs/@nue/app-router.js'
// import business model (the JS heavy, non-UI functionality)
import model from './model/index.js'
</script>
<main @name="app">
<header>
<h1>{ title }</h1>
<p>{ description }</p>
</header>
<!-- navigation for our views (aka "pages" or "routes" )-->
<nav>
<a href="/nuejs">Users</a>
<a href="/nuejs/feedback">Feedback</a>
<a href="/nuejs/analytics">Analytics</a>
</nav>
<!-- container for the application views -->
<article id="container"/>
<!-- controller code -->
<script>
// after #container is mounted
mounted() {
// front page -> show users
router.on('/', async() => {
const users = await model.getUsers()
this.mountChild('users-view', container, { users })
})
// feedback page -> show feedback
router.on('/feedback', async() => {
const users = await model.getFeedback()
this.mountChild('feedback-view', container, { users })
})
// analytics page -> show analytics
router.on('/analytics', async() => {
const data = await model.getAnalytics()
this.mountChild('analytics-view', container, data)
})
// start routing & setup <nav> onclick handlers
router.start(this)
}
</script>
</main>