mirror of
https://github.com/kataras/iris.git
synced 2025-12-22 20:37:05 +00:00
simplify some examples
This commit is contained in:
@@ -1 +0,0 @@
|
||||
window.alert("app.js loaded from \"/");
|
||||
@@ -1,3 +0,0 @@
|
||||
body {
|
||||
background-color: black;
|
||||
}
|
||||
@@ -1,14 +1,19 @@
|
||||
<html>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<title>{{ .Page.Title }}</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Iris SPA Router Example</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1> Hello from index.html </h1>
|
||||
|
||||
<div id="app">
|
||||
</div>
|
||||
|
||||
<script src="/app.js"> </script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
|
||||
<script src="./index.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,21 @@
|
||||
const NotFound = { template: '<p>Page not found</p>' }
|
||||
const Home = { template: '<p>home page</p>' }
|
||||
const About = { template: '<p>about page</p>' }
|
||||
|
||||
const routes = {
|
||||
'/': Home,
|
||||
'/about': About
|
||||
}
|
||||
|
||||
const app = new Vue({
|
||||
el: '#app',
|
||||
data: {
|
||||
currentRoute: window.location.pathname
|
||||
},
|
||||
computed: {
|
||||
ViewComponent () {
|
||||
return routes[this.currentRoute] || NotFound
|
||||
}
|
||||
},
|
||||
render (h) { return h(this.ViewComponent) }
|
||||
})
|
||||
Reference in New Issue
Block a user