vue2 系列:vue

编程入门 行业动态 更新时间:2024-10-28 20:23:35

vue2 <a href=https://www.elefans.com/category/jswz/34/1770787.html style=系列:vue"/>

vue2 系列:vue

前言:vue2.0 支持 ts,需要用到 vue-property-decorator

1. 安装

npm i -D vue-property-decorator

2. 用法

// vue, compnent 必引入,其他按需引用
import { Vue, Component, Prop, PropSync, Watch, Emit } from "vue-property-decorator";
// 必须的
@Component();
export default class Demo extends Vue {// Prop, ! 表示非 null,非 undefined@Prop({ default: 18 })age!: number;// PropSync, 实现组件双向绑定,可以修改传过来的值@PropSync('sex', { type: String })syncedsex!: string;// dataname: string = 'yqcoder';// Watch@Watch('name', { immediate: true, deep: true })onChangeName(new, old) {}// computedget nameL() {return this.name.length}// Emit: this.$emit('reset-name', 'yq')@Emit()resetName() {return 'yq'}
}

更多推荐

vue2 系列:vue

本文发布于:2023-12-03 10:33:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1654368.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:系列   vue

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!