當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。