-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path4. inline templates.html
64 lines (50 loc) · 2 KB
/
4. inline templates.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
<!DOCTYPE html>
<html>
<head>
<title>Inline Templates</title>
<script type="text/javascript" src="https://vuejs.org/js/vue.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
</head>
<body>
<div id="my-app" class="">
<div class="container pt-4">
<h1>Component Template X</h1>
<customisable inline-template>
<div class="card my-4"> <!-- This is the root element -->
<ul class="list-group">
<li class="list-group-item" v-for="tip in tips">{{ tip }}</li>
</ul>
</div>
</customisable>
<h1>Component Template Y</h1>
<customisable inline-template>
<div class="my-4"> <!-- This is the root element -->
<div class="card p-2 mb-2" v-for="(tip, index) in tips">
<div clas="card-body">
<h3 class="card-title">Tip #{{ index + 1 }}</h3>
<p class="card-text">{{ tip }}</p>
</div>
</div>
</div>
</customisable>
</div>
</div>
<script type="text/javascript">
Vue.component('customisable', {
data() {
return {
tips: [
"Sometimes you don't want to render the template via JS, e.g if you need to use PHP inside it, or for SEO reasons",
'So tag your component with the "inline-template" attribute',
'You must then set a root component within it, normally a div is fine',
'You might even need a whole bunch of different markup, but the same functionality'
]
}
}
})
new Vue({
el: '#my-app'
})
</script>
</body>
</html>