父子组件数据双向绑定
<template>
<van-field class="our-field-normal"
:value="this.va"
:label="this.label"
:placeholder="this.place"
@input="handleChange"></van-field>
</template>
<script lang="ts">
import {Component, Prop, Vue} from "vue-property-decorator";
@Component
export default class OurFieldNormal extends Vue {
//name: "our_field_normal"
@Prop()
private va!: string;
@Prop()
private label!: string;
@Prop()
private place!: string;
private handleChange(event: any) {
this.$emit('input', event);//关键所在,input事件会修改父组件value的值
}
}
</script>Last updated