Vue.jsチュートリアル_1
2268 ワード
{{ message }}
var app = new Vue({
el: "#app",
data: {
message: "hello Vue!"
}
})
!
命令は、「この要素ノードのtitle特性とVueインスタンスのmessage属性を一致させる」ことを意味する.ブラウザのConsoleでidとして作成するVueインスタンスを変更する.Message=「hello hello」で、Webページの内容がリアルタイムで変わります.v-if
例えば
var app3 = new Vue({
el: "#app-3",
data:{
seen: true
}
})
app3.seen=false; // 。
v-for
:使用例
-
{{ todo.text }}
var app4 = new Vue({
el: "#app-4",
data:{
todos:[
{text: "learning JavaScript"},
{text: "learning Vue"},
{text: "do some project"}
]
}
})
app4.todos.push({text:"new project"})
;2): app4.todos.pop()
v-on
命令イベントリスナー
{{ message }}
var app5 = new Vue({
el: '#app-5',
data: {
message: 'Hello Vue.js!'
},
methods: {
reverseMessage: function () {
this.message = this.message.split('').reverse().join('')
}
}
})
v-model
{{ message }}
var app6 = new Vue({
el: '#app-6',
data: {
message: 'Hello Vue!'
}
})
// todo-item
Vue.component('todo-item', {
template: ' '
})
var app = new Vue(...)