vue 打字效果_打字稿装饰器,使Vue更具打字稿感

本文介绍了如何使用TypeScript装饰器在Vue中实现打字效果,包括安装、特性、用法和示例。@VueComponent用于注册Vue组件,@Prop将变量添加到prop对象,@Watch用于监听属性变化。示例展示了纯打字稿、带有生命周期钩子的混合对象以及如何与vue-router集成。
摘要由CSDN通过智能技术生成

vue 打字效果

Vue打字稿 (vue-typescript)

Typescript decorators to make vue play nice with typescript.

打字机装饰器,以使vue与打字机配合使用。

安装 (Install)

This package has one single peer-dependancy: Vue (obviously)

该程序包具有单个对等项依赖关系:Vue(显然)

npm install --save vue-typescript

For the best experience you will want to use typings and typings install --save --global dt~vue as some decorators use these typings for input parameters. If you dont want to use them, the typed vue object will be handled as any.

为了获得最佳体验,您将要使用typings install --save --global dt~vuetypings install --save --global dt~vuetypings install --save --global dt~vue因为某些装饰器typings install --save --global dt~vue这些键入用作输入参数。 如果您不想使用它们,则键入的vue对象将被视为any

Alternatively, clone the vue-typescript-seed repo

或者,克隆vue-typescript-seed回购

特征 (Features)

  • @VueComponent - A class decorator that registers the class as a vue component

    @VueComponent-类装饰器,将类注册为vue组件

  • @Prop - A variable decorator that adds a class' variables to the prop object instead of data

    @Prop-变量修饰器,将类的变量添加到prop对象而不是数据

  • @Watch - A variable or function decorator that adds a property to the watch object mapping the desired function as handler

    @Watch-变量或函数修饰器,将属性添加到将所需函数映射为处理程序的watch对象

  • Computed Properties - to define computed properties, simply use the native typescript syntax get and set (see example below)

    计算属性 -要定义计算属性,只需使用本机打字脚本语法getset (请参见下面的示例)

用法 (Usage)

@VueComponent (@VueComponent)

There are 4 ways to call it:

有四种调用方法:

    @VueComponent     @VueComponent(element:string)     @VueComponent(options:ComponentOption)     @VueComponent(element:string, options:ComponentOption)      element - string to use as html tag      options - the same object as the one you would use when calling Vue.component

@VueComponent @VueComponent(element:string) @VueComponent(options:ComponentOption) @VueComponent(element:string, options:ComponentOption)元素-用作html标签选项的字符串-与调用Vue时使用的对象相同。零件

By default, the tag will be the snake-case version of the cla

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值