当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript vue-class-component.createDecorator函数代码示例

本文整理汇总了TypeScript中vue-class-component.createDecorator函数的典型用法代码示例。如果您正苦于以下问题:TypeScript createDecorator函数的具体用法?TypeScript createDecorator怎么用?TypeScript createDecorator使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了createDecorator函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: Option

/**
 * decorator of model
 * @param {any}  value option value
 * @return {Function} VueDecorator
 */
export default function Option(value): Function {
  return createDecorator((componentOptions: Record<string, any>, k) => {
    if (!componentOptions.options) {
      componentOptions.options = {};
    }
    componentOptions.options[k] = value;
  });
}
开发者ID:tinymins,项目名称:ChromeExt.GoogleExchange,代码行数:13,代码来源:option.ts

示例2: Watch

export function Watch(path: string, options: WatchOptions = {}): MethodDecorator {
  const { deep = false, immediate = false } = options

  return createDecorator((componentOptions, handler) => {
    if (typeof componentOptions.watch !== 'object') {
      componentOptions.watch = Object.create(null)
    }
    (componentOptions.watch as any)[path] = { handler, deep, immediate }
  })
}
开发者ID:shiLiangGit,项目名称:vue-property-decorator,代码行数:10,代码来源:vue-property-decorator.ts

示例3: Inject

export function Inject(options?: { from?: InjectKey, default?: any } | InjectKey): PropertyDecorator {
  return createDecorator((componentOptions, key) => {
    if (typeof componentOptions.inject === 'undefined') {
      componentOptions.inject = {}
    }
    if (!Array.isArray(componentOptions.inject)) {
      componentOptions.inject[key] = options || key
    }
  })
}
开发者ID:shiLiangGit,项目名称:vue-property-decorator,代码行数:10,代码来源:vue-property-decorator.ts

示例4: Provide

export function Provide(key?: string | symbol): PropertyDecorator {
  return createDecorator((componentOptions, k) => {
    let provide: any = componentOptions.provide
    if (typeof provide !== 'function' || !provide.managed) {
      const original = componentOptions.provide
      provide = componentOptions.provide = function (this: any) {
        let rv = Object.create((typeof original === 'function' ? original.call(this) : original) || null)
        for (let i in provide.managed) rv[provide.managed[i]] = this[i]
        return rv
      }
      provide.managed = {}
    }
    provide.managed[k] = key || k
  })
}
开发者ID:shiLiangGit,项目名称:vue-property-decorator,代码行数:15,代码来源:vue-property-decorator.ts

示例5: Prop

export function Prop(options: (PropOptions | Constructor[] | Constructor) = {}): PropertyDecorator {
  return createDecorator((componentOptions, k) => {
    (componentOptions.props || (componentOptions.props = {}) as any)[k] = options
  })
}
开发者ID:shiLiangGit,项目名称:vue-property-decorator,代码行数:5,代码来源:vue-property-decorator.ts

示例6: Model

export function Model(event?: string, options: (PropOptions | Constructor[] | Constructor) = {}): PropertyDecorator {
  return createDecorator((componentOptions, k) => {
    (componentOptions.props || (componentOptions.props = {}) as any)[k] = options
    componentOptions.model = { prop: k, event: event || k }
  })
}
开发者ID:shiLiangGit,项目名称:vue-property-decorator,代码行数:6,代码来源:vue-property-decorator.ts


注:本文中的vue-class-component.createDecorator函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。