GithubHelp home page GithubHelp logo

Comments (4)

ModyQyW avatar ModyQyW commented on June 20, 2024 1

好提议。我觉得可以拆分成两个 PR。

一个 PR 补充所有组件的 event 类型,如 SwiperOnChangeEvent 等。

另一个 PR 调整事件的实现,下面是一个例子。 #34 (comment)

interface _SwiperOnChange {
  // PR 前
  (event: CustomEvent<_SwiperOnChangeDetail>): void;
  // PR 后
  (event: CustomEvent<_SwiperOnChangeDetail>, ...params: any[]): void;
}

最近公司业务比较紧,我可能会稍晚一点提交这两个 PR 😅。当然也欢迎提交 PR 做相关实现!

from uni-app-types.

Megasu avatar Megasu commented on June 20, 2024

👌 已提交 PR 调整事件的实现。

from uni-app-types.

Megasu avatar Megasu commented on June 20, 2024

关于事件的类型还有个问题想讨论一下。

疑惑

疑惑:自定义事件类型 CustomEvent 是出于什么考虑把 detail 属性调整成可选属性。

代码对比

原生微信小程序的 CustomEvent类型声明

/*! *****************************************************************************
Copyright (c) 2023 Tencent, Inc. All rights reserved.
***************************************************************************** */
/** 自定义事件 */
interface CustomEvent<
    Detail extends IAnyObject = IAnyObject,
    Mark extends IAnyObject = IAnyObject,
    CurrentTargetDataset extends IAnyObject = IAnyObject,
    TargetDataset extends IAnyObject = CurrentTargetDataset
> extends BaseEvent<Mark, CurrentTargetDataset, TargetDataset> {
    /** 额外的信息 */
    detail: Detail
}

UniHelperCustomEvent类型声明

/** 自定义事件 */
interface _CustomEvent<
  Detail extends AnyRecord = AnyRecord,
  Mark extends AnyRecord = AnyRecord,
  CurrentTargetDataset extends AnyRecord = AnyRecord,
  TargetDataset extends AnyRecord = CurrentTargetDataset,
> extends _BaseEvent<Mark, CurrentTargetDataset, TargetDataset> {
  /** 额外信息,变成可选属性,目前不清楚您的出发点,可以交流一下🤔 */
  detail?: Detail;
  [key: string]: any;
}

带来的影响

image

预期效果

image

from uni-app-types.

ModyQyW avatar ModyQyW commented on June 20, 2024

已经增加 XxxEvent 类型啦!非常感谢🙏

from uni-app-types.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.