v-for和v-once的用法
阿新 • • 發佈:2018-11-09
<template>
<div id="app">
<h1>Hello Vuex</h1>
<p>{{aaa}}</p>
<button @click="add">+</button>
<button @click="sub">-</button>
<ul>
<li v-for="(item,index) in items">
{ {index}}--{{item.message}}
</li>
</ul>
<p v-once>原始資料:{{aaa}}</p>
<p>修改過的資料:{{aaa}}</p>
</div>
</template>
<script>
export default {
data(){
return{
aaa:2,
items:[
{ message:'first'},
{message:'second'}
]
}
},
methods:{
add:function(){
this.aaa++
},
sub:function(){
this.aaa--
}
}
}
</script>