1.1.17 • Published 9 months ago

mxp-uni-types v1.1.17

Weekly downloads
-
License
MIT
Repository
-
Last release
9 months ago

介绍

基于@uni-helper/uni-app-types实现用于 uniapp 的原生组件类型

安装

npm i mxp-uni-types
// 或
pnpm i mxp-uni-types
// 或
yarn add mxp-uni-types

使用

配置 tsconfig.json,确保 compilerOptions.types 中含有 @dcloudio/typesmxp-uni-types

{
  "compilerOptions": {
    "types": ["@dcloudio/types", "mxp-uni-types"]
  },
  "include": ["src/**/*.vue"]
}

标注类型

推荐使用 mxp-uni-types 导出的类型为变量标注类型。

<script setup lang="ts">
  import { ref } from 'vue';
  import type { ScrollViewOnScroll } from 'mxp-uni-types';

  const onScroll: ScrollViewOnScroll = (event) => {
    ...
  };
</script>

<template>
  <scroll-view @scroll="onScroll"></scroll-view>
</template>

也可以直接使用命名空间来为变量标注类型。

<script setup lang="ts">
  import { ref } from 'vue';

  const onScroll: GUni.ScrollViewOnScroll = (event) => {
    ...
  };
</script>

<template>
  <scroll-view @scroll="onScroll"></scroll-view>
</template>

如果你需要传入事件之外的参数,可以参考以下例子。参数顺序参考了 Vue 文档的示例(见 在内联事件处理器中访问事件参数)。

<script setup lang="ts">
  import { ref } from 'vue';
  import type { ScrollViewOnScrollEvent } from 'mxp-uni-types';

  const onScroll = (text: string, event: ScrollViewOnScrollEvent) => {
    ...
  };
</script>

<template>
  <scroll-view @scroll="onScroll('ScrollViewA', $event)"></scroll-view>
  <scroll-view @scroll="onScroll('ScrollViewB', $event)"></scroll-view>
</template>

致谢

基于@uni-helper/uni-app-types实现

1.1.1

10 months ago

1.1.9

10 months ago

1.1.8

10 months ago

1.1.7

10 months ago

1.1.6

10 months ago

1.1.5

10 months ago

1.1.4

10 months ago

1.1.3

10 months ago

1.1.2

10 months ago

1.1.12

10 months ago

1.1.11

10 months ago

1.1.10

10 months ago

1.1.16

9 months ago

1.1.15

10 months ago

1.1.14

10 months ago

1.1.17

9 months ago

1.0.19

1 year ago

1.0.18

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.22

1 year ago

1.0.21

1 year ago

1.0.20

1 year ago

1.0.26

1 year ago

1.0.25

1 year ago

1.0.24

1 year ago

1.0.23

1 year ago

1.0.29

1 year ago

1.0.28

1 year ago

1.0.27

1 year ago

1.0.31

1 year ago

1.0.30

1 year ago

1.0.37

12 months ago

1.0.36

12 months ago

1.0.35

12 months ago

1.1.0

11 months ago

1.0.39

12 months ago

1.0.40

12 months ago

1.0.44

11 months ago

1.0.43

11 months ago

1.0.42

12 months ago

1.0.41

12 months ago

1.0.48

11 months ago

1.0.47

11 months ago

1.0.46

11 months ago

1.0.45

11 months ago

1.0.49

11 months ago

1.0.50

11 months ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago