-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdemo.html
92 lines (85 loc) · 2.32 KB
/
demo.html
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>vue-router-then</title>
<body>
<div id="app">
<keep-alive>
<router-view></router-view>
</keep-alive>
</div>
<script src="https://npmcdn.com/vue/dist/vue.js"></script>
<script src="https://npmcdn.com/vue-router/dist/vue-router.js"></script>
<script src="./dist/index.min.js"></script>
<script>
const home = {
template: '<div>\
<div>[HOME]</div>\
<h2>ex.1 useage of v-model-link</h2>\
<div>chose: <input v-model="choseValue" v-model-link="\'/chose\'" @input="modelLinkCallback" /></div>\
<h2>ex.2 useage of $routerThen</h2>\
<div><input type="text" v-model="message"/><button @click="routerThenClick">GO</button></div>\
</div>\
',
data() {
return {
message: 'hello, world.',
choseValue: '?',
}
},
methods: {
routerThenClick: function() {
this.$routerThen.push('/chose').then(vm => {
vm.msg = this.message;
vm.$once('input', value => {
this.choseValue = value;
});
});
},
modelLinkCallback: function(value) {
console.log(value);
},
}
}
const chose = {
template: '<div>\
<div @click="goBack">< back</div>\
<button @click="chose(\'A\')">A</button>\
<button @click="chose(\'B\')">B</button>\
<button @click="chose(\'C\')">C</button>\
<button @click="chose(\'D\')">D</button>\
<div> {{msg}} </div>\
</div>',
data() {
return {
msg: '????, ?????.',
}
},
mounted: function() {
this.time = new Date().getTime()
},
methods: {
goBack: function() {
this.$router.go(-1);
},
chose: function(r) {
this.$emit('input', r);
this.$router.go(-1);
},
}
}
const router = new VueRouter({
routes: [
{path: '/',component: home},
{path: '/chose',component: chose},
{path: '*',component: home}, ]
})
new Vue({
router,
el: '#app',
})
$routerThen.initRouter(router);
</script>
</body>
</html>