api-typings icon indicating copy to clipboard operation
api-typings copied to clipboard

组件属性是自定义的类型该如何定义?

Open jq94666 opened this issue 4 years ago • 3 comments

例如

Component({
  properties: {
    coupon: CouponBO
  },

我想通过this.properties.coupon获得类型提示,应该怎么写呢?

jq94666 avatar Jan 23 '21 01:01 jq94666

同,应该怎么写呢

zch233 avatar Jan 29 '21 06:01 zch233

可能是这样

const data: { a: string[] } = { a: [] }
const properties: {
  b: ArrayConstructor,
  c: { type: ArrayConstructor, value: any[] },
} = {
  b: Array,
  c: { type: Array, value: [] },
}
Component({ data, properties })

zch233 avatar Jan 29 '21 06:01 zch233

@jq94666 你可以了吗

hopkinson avatar Nov 25 '21 02:11 hopkinson