-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.html
94 lines (92 loc) · 2.97 KB
/
index.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
93
94
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Gengine</title>
</head>
<body>
<!-- <div id="mvvm-app">
<input type="text" v-model="someStr">
<input type="text" v-model="child.someStr">
<p v-class="className" class="abc">
{{someStr}}
<span v-text="child.someStr"></span>
</p>
<p>{{ getHelloWord }}</p>
<p v-html="htmlStr"></p>
<button v-on:click="clickBtn">change model</button>
</div> -->
<script type="module">
import Geg from './dist/geg.js'
Geg.component('blog-post', {
// 在 JavaScript 中是 camelCase 的
props: ['postTitle'],
template: '<h3>{{ postTitle }}</h3>',
mounted() {
this.$emit('customeve', 'helloworld')
}
})
var vm = new Geg({
el: './test.xml',// #mvvm-app
directives: {
focus: {
// 指令的定义
inserted: function (el) {
// el.focus()
console.log(el)
}
}
},
data: {
someStr: 'hello ',
className: 'btn',
childCompName: '嗯,这是子组件',
isRun: false,
child: {
someStr: 'World !'
},
todos: [
{ text: '学习 JavaScript' },
{ text: '学习 Vue' },
{ text: '整个牛项目' }
],
testArr: ['hello', 'world', 'linux']
},
props: {
curName: {
default: 'getCurrName'
}
},
// template: '<div :halo="129"><div v-if="isRun"><span>v-if is run</span></div><span :align="\'center\'" :text="someStr">{{someStr}}<a :engine="100"></a></span></div>',
// template: '<ol><blog-post v-focus :post-title="childCompName"></blog-post><li :text = "className" v-for="todo in todos">{{ todo.text }}</li></ol>',
computed: {
getHelloWord: function() {
return this.someStr + this.child.someStr
}
},
beforeUpdate() {
},
beforeMount() {
},
mounted() {
console.log(this)
},
beforeCreate() {
},
created() {
},
methods: {
clickBtn: function(e) {
console.log(e)
var randomStrArr = ['childOne', 'childTwo', 'childThree']
this.someStr = randomStrArr[parseInt(Math.random() * 3)]
console.log(this.someStr)
}
}
});
// vm.$watch('someStr', function() {
// console.log(arguments);
// });
</script>
</body>
</html>