<script></script> format
<script>
var app = new Vue ({ el:'#app', //element data: { message: "Hello World!", //render data todos: [ { text: 'Vue' }, { text: 'Js' } ] }, //function methods: { countNumber: function () { this.count += 1 } }, //function, when elements(firstname/lastname) change, the fullname change computed: { fullname: function () { return this.firstname + this.lastname } } })
</script>
v-*
- v-text
- v-html
- v-show //if it is true, it will show this element, else hiding the element
- v-if //like v-show, but it doesn't display html if it is false
- v-else //v-if, v-else
- v-pre //display the pure text instead of rendering it
- v-once //just render once
- v-cloak //do it before Vue ends loading
[v-cloak] { background-color: red; }
- v-bind: title = "title" //"v-bind:" can be replaced by ":"
- v-for
/*see script in 1.*/
<template> <ul> <li v-for=“todo in todos”>{{ todo.id }} {{ todo.text }}</li> </ul> </template> - v-model //bind view to model(view-model, {{}}: model-view)
<input type = “text” v-model=“message” /> <!--when you input message, it change the message in data-->
- v-on: or @
<button @click=“countNumber”></button>
- s
reference: "Vue.js 2.0 Fundamentals" from YouTube (https://www.youtube.com/channel/UC6kwT7-jjZHHF1s7vCfg2CA/videos)
浙公网安备 33010602011771号