-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomponent.html
65 lines (46 loc) · 1.02 KB
/
component.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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Vue JS - Component</title>
</head>
<body>
<div id="app">
{{a}}
<hyder-component>
<my-component></my-component>
</hyder-component>
</div>
<script src="js/vue.min.js"></script>
<script>
var Child = Vue.extend({
template: '<div>A custom component! - {{a}} {{message}}</div>',
data: function(){
return {a:100}
}
})
// register
Vue.component('my-component', Child)
Vue.component('hyder-component', Parent)
var Parent = Vue.extend({
template: '<div class="parent-template">This is my parent\'s template</div>',
components: {
// <my-component> will only be available in Parent's template
'my-component': Child
}
})
// create a root instance
new Vue({
el: '#app',
data:{
message:"Heye"
}
})
</script>
<style>
.error{
color: red;
}
</style>
</body>
</html>