1、声明函数
private、public、protected
private formStatus: string = 'create'
private form: formDTO = {
account: '',
password: ''
}
2、@ 装饰器(替换钩子函数)
- 从
vue-property-decorator
引入相应的装饰器(Component, Prop, Watch...
)!:
表示强制解析, 告诉ts编辑器一定有值
@Component
必须得有- 相关装饰器的用法
<script lang="ts">
import { Component, Prop, Watch, Vue } from "vue-property-decorator";
import vHead from './header.vue';
interface formDTO {
account: string,
password: string
}
@Component({
components: {
vHead,
},
})
export default class Test extends Vue {
@Prop({
type: Object,
required: false,
default: {}
}) formData !: object
@Watch('formData', { immediate: true, deep: true })
private onFormDatachanged(val: any){
// console.log(val)
this.currentId = val.id;
this.formStatus = val.dialogStatus;
}
private formStatus: string = 'create'
private form: formDTO = {
account: '',
password: ''
}
};
</script>