javascript
murata vue.js å…¬å¼ãƒ‰ã‚ュメント
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="app">
app1
{{ message }}
</div>
<div id="app-2">
app2
<span v-bind:title="message">
Hover your mouse over me for a few seconds
to see my dynamically bound title!
</span>
</div>
<div id="app-3">
app3
<span v-if="seen">Now you see me</span>
</div>
<div id="app-4">
app4
<ol>
<li v-for="todo in todos">
{{ todo.text }}
</li>
</ol>
</div>
<div id="app-5">
app5
<p>{{ message }}</p>
<button v-on:click="reverseMessage">Reverse Message</button>
</div>
<div id="app-6">
app6
<p>{{ message }}</p>
<input v-model="message">
</div>
<div id="app-7">
app7
<ol>
<!--
Now we provide each todo-item with the todo object
it's representing, so that its content can be dynamic.
We also need to provide each component with a "key",
which will be explained later.
-->
<mitsu-item
v-for="item in groceryList"
v-bind:mitsutodo="item"
v-bind:key="item.idmitsu"
></mitsu-item>
</ol>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
<script>
var app = new Vue({
el: '#app',
data: {
message: 'Hello mitsu!'
}
})
var app2 = new Vue({
el: '#app-2',
data: {
message: 'You loaded this page on ' + new Date().toLocaleString()
}
})
var app3 = new Vue({
el: '#app-3',
data: {
seen: true
}
})
var app4 = new Vue({
el: '#app-4',
data: {
todos: [
{ text: 'Learn JavaScript' },
{ text: 'Learn Vue' },
{ text: 'Build something awesome' }
]
}
})
var app5 = new Vue({
el: '#app-5',
data: {
message: 'Hello Vue.js!'
},
methods: {
reverseMessage: function () {
this.message = this.message.split('').reverse().join('')
}
}
})
var app6 = new Vue({
el: '#app-6',
data: {
message: 'Hello Vue!'
}
})
Vue.component('mitsu-item', {
props: ['mitsutodo'],
template: '<li>{{ mitsutodo.nakami }}</li>'
})
var app7 = new Vue({
el: '#app-7',
data: {
groceryList: [
{ idmitsu: 0, nakami: 'Vegetables' },
{ idmitsu: 1, nakami: 'Cheese' },
{ idmitsu: 2, nakami: 'Whatever else humans are supposed to eat' }
]
}
})
</script>
</body>
</html>
Was this helpful?
Similar Posts