vue数据双向绑定,新增参数记录一些问题
作者:互联网
<template>
<div class="hello">
<p>所有车位:{{total}}</p>
<p>虚拟车位:{{this.form.virtual}}</p>
<p>固定车位:{{this.form.fixedparking}}</p>
<button @click="form.virtual++">virtual++</button>
<button @click="form.fixedparking++">fixedparking++</button>
<input v-model="form.fixedparking">
</div>
</template>
<script>
import Vue from 'vue'
export default {
name: 'HelloWorld',
props: {
msg: String
},
data(){
return {
form:{
virtual:10,
// fixedparking:[],
}
}
},
mounted(){
this.getparms()
},
methods:{
getparms(){
//Vue.set(this.form,'fixedparking',3)
this.form.fixedparking = 2
},
changeid(){
this.form.fixedparking++
}
},
computed:{
total(){
return this.form.fixedparking+this.form.virtual
}
}
}
</script>
标签:vue,form,++,绑定,virtual,fixedparking,双向,total,车位 来源: https://www.cnblogs.com/gzeal/p/16316943.html