lib.wx.event.d.ts 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435
  1. /*! *****************************************************************************
  2. Copyright (c) 2021 Tencent, Inc. All rights reserved.
  3. Permission is hereby granted, free of charge, to any person obtaining a copy of
  4. this software and associated documentation files (the "Software"), to deal in
  5. the Software without restriction, including without limitation the rights to
  6. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  7. of the Software, and to permit persons to whom the Software is furnished to do
  8. so, subject to the following conditions:
  9. The above copyright notice and this permission notice shall be included in all
  10. copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  17. SOFTWARE.
  18. ***************************************************************************** */
  19. declare namespace WechatMiniprogram {
  20. interface Target<DataSet extends IAnyObject = IAnyObject> {
  21. /** 事件组件的 id */
  22. id: string
  23. /** 当前组件的类型 */
  24. tagName?: string
  25. /** 事件组件上由 `data-` 开头的自定义属性组成的集合 */
  26. dataset: DataSet
  27. /** 距离页面顶部的偏移量 */
  28. offsetTop: number
  29. /** 距离页面左边的偏移量 */
  30. offsetLeft: number
  31. }
  32. /** 基础事件参数 */
  33. interface BaseEvent<
  34. Mark extends IAnyObject = IAnyObject,
  35. CurrentTargetDataset extends IAnyObject = IAnyObject,
  36. TargetDataset extends IAnyObject = CurrentTargetDataset
  37. > {
  38. /** 事件类型 */
  39. type: string
  40. /** 页面打开到触发事件所经过的毫秒数 */
  41. timeStamp: number
  42. /** 事件冒泡路径上所有由 `mark:` 开头的自定义属性组成的集合 */
  43. mark?: Mark
  44. /** 触发事件的源组件 */
  45. target: Target<TargetDataset>
  46. /** 事件绑定的当前组件 */
  47. currentTarget: Target<CurrentTargetDataset>
  48. }
  49. /** 自定义事件 */
  50. interface CustomEvent<
  51. Detail extends IAnyObject = IAnyObject,
  52. Mark extends IAnyObject = IAnyObject,
  53. CurrentTargetDataset extends IAnyObject = IAnyObject,
  54. TargetDataset extends IAnyObject = CurrentTargetDataset
  55. > extends BaseEvent<Mark, CurrentTargetDataset, TargetDataset> {
  56. /** 额外的信息 */
  57. detail: Detail
  58. }
  59. /** Touch 对象 */
  60. interface TouchDetail {
  61. /** 距离页面可显示区域 (屏幕除去导航条) 左上角距离,横向为 X 轴 */
  62. clientX: number
  63. /** 距离页面可显示区域 (屏幕除去导航条) 左上角距离,纵向为 Y 轴 */
  64. clientY: number
  65. /** 触摸点的标识符 */
  66. identifier: number
  67. /** 距离文档左上角的距离,文档的左上角为原点,横向为 X 轴 */
  68. pageX: number
  69. /** 距离文档左上角的距离,文档的左上角为原点,纵向为 Y 轴 */
  70. pageY: number
  71. }
  72. /** canvas Touch 对象 */
  73. interface TouchCanvasDetail {
  74. /** 触摸点的标识符 */
  75. identifier: number
  76. /** 距离 Canvas 左上角的距离,Canvas 的左上角为原点 ,横向为X轴 */
  77. x: number
  78. /** 距离 Canvas 左上角的距离,Canvas 的左上角为原点 纵向为Y轴 */
  79. y: number
  80. }
  81. /** 触摸事件 */
  82. interface Touch<
  83. Detail extends IAnyObject = IAnyObject,
  84. T extends TouchDetail | TouchCanvasDetail = TouchDetail,
  85. Mark extends IAnyObject = IAnyObject,
  86. CurrentTargetDataset extends IAnyObject = IAnyObject,
  87. TargetDataset extends IAnyObject = CurrentTargetDataset
  88. > extends CustomEvent<Detail, Mark, CurrentTargetDataset, TargetDataset> {
  89. /** 触摸事件,当前停留在屏幕中的触摸点信息的数组 */
  90. touches: T[]
  91. /** 触摸事件,当前变化的触摸点信息的数组 */
  92. changedTouches: T[]
  93. }
  94. /** 触摸事件响应 */
  95. type TouchEvent<
  96. Detail extends IAnyObject = IAnyObject,
  97. Mark extends IAnyObject = IAnyObject,
  98. CurrentTargetDataset extends IAnyObject = IAnyObject,
  99. TargetDataset extends IAnyObject = CurrentTargetDataset
  100. > = Touch<Detail, TouchDetail, Mark, CurrentTargetDataset, TargetDataset>
  101. /** canvas 触摸事件响应 */
  102. interface TouchCanvas<
  103. Mark extends IAnyObject = IAnyObject,
  104. TargetDataset extends IAnyObject = IAnyObject
  105. > extends Touch<never, TouchCanvasDetail, Mark, never, TargetDataset> {
  106. // canvas 中的触摸事件不可冒泡,所以没有 currentTarget。
  107. currentTarget: never
  108. }
  109. /**
  110. * 图片加载成功时触发
  111. *
  112. * 最低基础库: 2.1.0
  113. */
  114. type CoverImageLoad<
  115. Mark extends IAnyObject = IAnyObject,
  116. TargetDataset extends IAnyObject = IAnyObject
  117. > = CustomEvent<
  118. {
  119. /** 图片宽度 */
  120. width: number
  121. /** 图片高度 */
  122. height: number
  123. },
  124. Mark,
  125. TargetDataset
  126. >
  127. /**
  128. * 图片加载失败时触发
  129. *
  130. * 最低基础库: 2.1.0
  131. */
  132. type CoverImageError = CustomEvent<GeneralCallbackResult>
  133. /**
  134. * 拖动过程中触发的事件,event.detail = {x, y, source}
  135. *
  136. * 最低基础库: 1.9.90
  137. */
  138. type MovableViewChange<
  139. Mark extends IAnyObject = IAnyObject,
  140. TargetDataset extends IAnyObject = IAnyObject
  141. > = CustomEvent<
  142. {
  143. x: number
  144. y: number
  145. /**
  146. * 产生移动的原因
  147. *
  148. * - `touch` 拖动
  149. * - `touch-out-of-bounds` 超出移动范围
  150. * - `out-of-bounds` 超出移动范围后的回弹
  151. * - `friction` 惯性
  152. * - `空字符串` setData
  153. */
  154. source:
  155. | 'touch'
  156. | 'touch-out-of-bounds'
  157. | 'out-of-bounds'
  158. | 'friction'
  159. | ''
  160. },
  161. Mark,
  162. TargetDataset
  163. >
  164. /**
  165. * 缩放过程中触发的事件
  166. *
  167. * event.detail = {x, y, scale}
  168. *
  169. * x 和 y 字段在 2.1.0 之后支持
  170. *
  171. * 最低基础库: 1.9.90
  172. */
  173. type MovableViewScale<
  174. Mark extends IAnyObject = IAnyObject,
  175. TargetDataset extends IAnyObject = IAnyObject
  176. > = CustomEvent<
  177. {
  178. /** 最低基础库: 2.1.0 */
  179. x: number
  180. /** 最低基础库: 2.1.0 */
  181. y: number
  182. scale: number
  183. },
  184. Mark,
  185. TargetDataset
  186. >
  187. /**
  188. * 滑动开始事件 (同时开启 enhanced 属性后生效)
  189. *
  190. * detail { scrollTop, scrollLeft }
  191. *
  192. * 最低基础库: 2.12.0
  193. */
  194. type ScrollViewDragStart<
  195. Mark extends IAnyObject = IAnyObject,
  196. TargetDataset extends IAnyObject = IAnyObject
  197. > = CustomEvent<
  198. {
  199. scrollTop: number
  200. scrollLeft: number
  201. },
  202. Mark,
  203. TargetDataset
  204. >
  205. /**
  206. * 滑动事件 (同时开启 enhanced 属性后生效)
  207. *
  208. * detail { scrollTop, scrollLeft }
  209. *
  210. * 最低基础库: 2.12.0
  211. */
  212. type ScrollViewDragging<
  213. Mark extends IAnyObject = IAnyObject,
  214. TargetDataset extends IAnyObject = IAnyObject
  215. > = CustomEvent<
  216. {
  217. scrollTop: number
  218. scrollLeft: number
  219. },
  220. Mark,
  221. TargetDataset
  222. >
  223. /**
  224. * 滑动结束事件 (同时开启 enhanced 属性后生效)
  225. *
  226. * detail { scrollTop, scrollLeft }
  227. *
  228. * 最低基础库: 2.12.0
  229. */
  230. type ScrollViewDragEnd<
  231. Mark extends IAnyObject = IAnyObject,
  232. TargetDataset extends IAnyObject = IAnyObject
  233. > = CustomEvent<
  234. {
  235. scrollTop: number
  236. scrollLeft: number
  237. },
  238. Mark,
  239. TargetDataset
  240. >
  241. /** 滚动到顶部/左边时触发 */
  242. type ScrollViewScrollToUpper<
  243. Mark extends IAnyObject = IAnyObject,
  244. TargetDataset extends IAnyObject = IAnyObject
  245. > = CustomEvent<
  246. {
  247. direction: 'top' | 'left'
  248. },
  249. Mark,
  250. TargetDataset
  251. >
  252. /** 滚动到底部/右边时触发 */
  253. type ScrollViewScrollToLower<
  254. Mark extends IAnyObject = IAnyObject,
  255. TargetDataset extends IAnyObject = IAnyObject
  256. > = CustomEvent<
  257. {
  258. direction: 'bottom' | 'right'
  259. },
  260. Mark,
  261. TargetDataset
  262. >
  263. /**
  264. * 滚动时触发
  265. *
  266. * event.detail = {scrollLeft, scrollTop, scrollHeight, scrollWidth, deltaX, deltaY}
  267. */
  268. type ScrollViewScroll<
  269. Mark extends IAnyObject = IAnyObject,
  270. TargetDataset extends IAnyObject = IAnyObject
  271. > = CustomEvent<
  272. {
  273. scrollLeft: number
  274. scrollTop: number
  275. scrollHeight: number
  276. scrollWidth: number
  277. deltaX: number
  278. deltaY: number
  279. },
  280. Mark,
  281. TargetDataset
  282. >
  283. type ScrollViewRefresherPulling<
  284. Mark extends IAnyObject = IAnyObject,
  285. TargetDataset extends IAnyObject = IAnyObject
  286. > = CustomEvent<never, Mark, TargetDataset>
  287. type ScrollViewRefresherRefresh<
  288. Mark extends IAnyObject = IAnyObject,
  289. TargetDataset extends IAnyObject = IAnyObject
  290. > = CustomEvent<never, Mark, TargetDataset>
  291. type ScrollViewRefresherRestore<
  292. Mark extends IAnyObject = IAnyObject,
  293. TargetDataset extends IAnyObject = IAnyObject
  294. > = CustomEvent<never, Mark, TargetDataset>
  295. type ScrollViewRefresherAbort<
  296. Mark extends IAnyObject = IAnyObject,
  297. TargetDataset extends IAnyObject = IAnyObject
  298. > = CustomEvent<never, Mark, TargetDataset>
  299. /**
  300. * current 改变时会触发 change 事件
  301. *
  302. * event.detail = {current, source}
  303. *
  304. * **Tip**: 如果在 bindchange 的事件回调函数中使用 setData 改变 current 值,则有可能导致 setData 被不停地调用,因而通常情况下请在改变 current 值前检测 source 字段来判断是否是由于用户触摸引起。
  305. */
  306. type SwiperChange<
  307. Mark extends IAnyObject = IAnyObject,
  308. TargetDataset extends IAnyObject = IAnyObject
  309. > = CustomEvent<
  310. {
  311. current: number
  312. /**
  313. * 表示导致变更的原因
  314. *
  315. * - `autoplay` 自动播放导致 swiper 变化;
  316. * - `touch` 用户划动引起 swiper 变化;
  317. * - 其它原因将用空字符串表示。
  318. *
  319. * 最低基础库: 1.4.0
  320. */
  321. source: '' | 'autoplay' | 'touch'
  322. /** 该 swiper-item 的标识符 */
  323. currentItemId: string
  324. },
  325. Mark,
  326. TargetDataset
  327. >
  328. /**
  329. * swiper-item 的位置发生改变时会触发 transition 事件
  330. *
  331. * event.detail = {dx: dx, dy: dy}
  332. *
  333. * 最低基础库: 2.4.3
  334. */
  335. type SwiperTransition<
  336. Mark extends IAnyObject = IAnyObject,
  337. TargetDataset extends IAnyObject = IAnyObject
  338. > = CustomEvent<
  339. {
  340. dx: number
  341. dy: number
  342. },
  343. Mark,
  344. TargetDataset
  345. >
  346. /**
  347. * 动画结束时会触发 animationfinish 事件
  348. *
  349. * 最低基础库: 1.9.0
  350. */
  351. type SwiperAnimationFinish<
  352. Mark extends IAnyObject = IAnyObject,
  353. TargetDataset extends IAnyObject = IAnyObject
  354. > = SwiperChange<Mark, TargetDataset>
  355. /**
  356. * progress 动画完成事件
  357. *
  358. * 最低基础库 2.4.1
  359. */
  360. type ProgressActiveEnd<
  361. Mark extends IAnyObject = IAnyObject,
  362. TargetDataset extends IAnyObject = IAnyObject
  363. > = CustomEvent<
  364. {
  365. curPercent: number
  366. },
  367. Mark,
  368. TargetDataset
  369. >
  370. /**
  371. * 用户点击该按钮时,会返回获取到的用户信息,回调的 detail 数据与 `wx. getUserInfo` 返回的一致,`open-type="getUserInfo"` 时有效
  372. *
  373. * 最低基础库: 1.3.0
  374. */
  375. type ButtonGetUserInfo = CustomEvent<
  376. GeneralCallbackResult & GetUserInfoSuccessCallbackResult
  377. >
  378. /**
  379. * 客服消息回调,`open-type="contact"` 时有效
  380. *
  381. * 最低基础库: 1.5.0
  382. */
  383. type ButtonContact = CustomEvent<GeneralCallbackResult>
  384. /**
  385. * 获取用户手机号回调,`open-type=getPhoneNumber` 时有效
  386. *
  387. * 最低基础库: 1.2.0
  388. */
  389. type ButtonGetPhoneNumber = CustomEvent<
  390. GeneralCallbackResult & Partial<GetWeRunDataSuccessCallbackResult>
  391. >
  392. /**
  393. * 当使用开放能力时,发生错误的回调,`open-type=launchApp` 时有效
  394. *
  395. * 最低基础库: 1.9.5
  396. */
  397. type ButtonError = CustomEvent<GeneralCallbackResult>
  398. /**
  399. * 在打开授权设置页后回调,`open-type=openSetting` 时有效
  400. *
  401. * 最低基础库: 2.0.7
  402. */
  403. type ButtonOpenSetting = CustomEvent<
  404. GeneralCallbackResult & OpenSettingSuccessCallbackResult
  405. >
  406. /**
  407. * 打开 APP 成功的回调,`open-type=launchApp` 时有效
  408. *
  409. * 最低基础库: 2.4.4
  410. */
  411. type ButtonLaunchApp = CustomEvent<GeneralCallbackResult>
  412. /**
  413. * checkbox-group 中选中项发生改变时触发 change 事件
  414. *
  415. * detail = { value: ['选中的checkbox 的 value 的数组'] }
  416. */
  417. type CheckboxGroupChange<
  418. Mark extends IAnyObject = IAnyObject,
  419. TargetDataset extends IAnyObject = IAnyObject
  420. > = CustomEvent<
  421. {
  422. /** 选中的 checkbox 的 value 的数组 */
  423. value: string[]
  424. },
  425. Mark,
  426. TargetDataset
  427. >
  428. /**
  429. * 编辑器初始化完成时触发
  430. *
  431. * 最低基础库: 2.7.0
  432. */
  433. type EditorReady<
  434. Mark extends IAnyObject = IAnyObject,
  435. TargetDataset extends IAnyObject = IAnyObject
  436. > = CustomEvent<never, Mark, TargetDataset>
  437. /**
  438. * 编辑器聚焦时触发
  439. *
  440. * event.detail = {html, text, delta}
  441. *
  442. * 最低基础库: 2.7.0
  443. */
  444. type EditorFocus<
  445. Mark extends IAnyObject = IAnyObject,
  446. TargetDataset extends IAnyObject = IAnyObject
  447. > = CustomEvent<
  448. {
  449. html: string
  450. text: string
  451. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  452. delta: any[]
  453. },
  454. Mark,
  455. TargetDataset
  456. >
  457. /**
  458. * 编辑器失去焦点时触发
  459. *
  460. * detail = {html, text, delta}
  461. *
  462. * 最低基础库: 2.7.0
  463. */
  464. type EditorBlur<
  465. Mark extends IAnyObject = IAnyObject,
  466. TargetDataset extends IAnyObject = IAnyObject
  467. > = EditorFocus<Mark, TargetDataset>
  468. /**
  469. * 编辑器内容改变时触发
  470. *
  471. * detail = {html, text, delta}
  472. *
  473. * 最低基础库: 2.7.0
  474. */
  475. type EditorInput<
  476. Mark extends IAnyObject = IAnyObject,
  477. TargetDataset extends IAnyObject = IAnyObject
  478. > = EditorFocus<Mark, TargetDataset>
  479. /**
  480. * 通过 Context 方法改变编辑器内样式时触发,返回选区已设置的样式
  481. *
  482. * 最低基础库: 2.7.0
  483. */
  484. type EditorStatusChange<
  485. Mark extends IAnyObject = IAnyObject,
  486. TargetDataset extends IAnyObject = IAnyObject
  487. > = CustomEvent<
  488. Partial<{
  489. align: 'left' | 'center' | 'right' | 'justify'
  490. bold: 'strong'
  491. italic: 'em'
  492. underline: true
  493. strike: 'del'
  494. lineHeight: string
  495. letterSpacing: string
  496. marginTop: string
  497. marginBottom: string
  498. fontFamily: string
  499. fontSize: string
  500. color: string
  501. backgroundColor: string
  502. list: 'checked' | 'unchecked' | 'ordered' | 'bullet'
  503. indent: number
  504. header: number
  505. script: 'sub' | 'super'
  506. direction: 'rtl'
  507. }>,
  508. Mark,
  509. TargetDataset
  510. >
  511. /**
  512. * 携带 form 中的数据触发 submit 事件
  513. *
  514. * event.detail = {value : {'name': 'value'} , formId: ''}
  515. */
  516. type FormSubmit<
  517. Mark extends IAnyObject = IAnyObject,
  518. TargetDataset extends IAnyObject = IAnyObject
  519. > = CustomEvent<
  520. {
  521. formId?: unknown
  522. target: Target
  523. /** 表单中的数据,需要在表单组件中加上 name 来作为 key。 */
  524. value: IAnyObject
  525. },
  526. Mark,
  527. TargetDataset
  528. >
  529. /** 表单重置时会触发 reset 事件 */
  530. type FormReset<
  531. Mark extends IAnyObject = IAnyObject,
  532. TargetDataset extends IAnyObject = IAnyObject
  533. > = CustomEvent<
  534. {
  535. target: Target
  536. },
  537. Mark,
  538. TargetDataset
  539. >
  540. /** 键盘输入时触发
  541. *
  542. * event.detail = {value, cursor, keyCode}
  543. *
  544. * 处理函数可以直接 return 一个字符串,将替换输入框的内容。
  545. */
  546. type Input<
  547. Mark extends IAnyObject = IAnyObject,
  548. TargetDataset extends IAnyObject = IAnyObject
  549. > = CustomEvent<
  550. {
  551. /** 输入框内容 */
  552. value: string
  553. /** 光标位置 */
  554. cursor: number
  555. /** keyCode 为键值 (目前工具还不支持返回keyCode参数) `2.1.0` 起支持 */
  556. keyCode?: number
  557. },
  558. Mark,
  559. TargetDataset
  560. >
  561. /**
  562. * 输入框聚焦时触发
  563. *
  564. * event.detail = { value, height }
  565. */
  566. type InputFocus<
  567. Mark extends IAnyObject = IAnyObject,
  568. TargetDataset extends IAnyObject = IAnyObject
  569. > = CustomEvent<
  570. {
  571. /** 输入框内容 */
  572. value: string
  573. /** 键盘高度, 在基础库 `1.9.90` 起支持 */
  574. height: number
  575. },
  576. Mark,
  577. TargetDataset
  578. >
  579. /**
  580. * 输入框失去焦点时触发
  581. *
  582. * event.detail = {value: value}
  583. */
  584. type InputBlur<
  585. Mark extends IAnyObject = IAnyObject,
  586. TargetDataset extends IAnyObject = IAnyObject
  587. > = CustomEvent<
  588. {
  589. /** 输入框内容 */
  590. value: string
  591. },
  592. Mark,
  593. TargetDataset
  594. >
  595. /**
  596. * 点击完成按钮时触发
  597. *
  598. * event.detail = {value: value}
  599. */
  600. type InputConfirm<
  601. Mark extends IAnyObject = IAnyObject,
  602. TargetDataset extends IAnyObject = IAnyObject
  603. > = CustomEvent<
  604. {
  605. /** 输入框内容 */
  606. value: string
  607. },
  608. Mark,
  609. TargetDataset
  610. >
  611. /**
  612. * 键盘高度发生变化的时候触发此事件
  613. *
  614. * event.detail = {height: height, duration: duration}
  615. *
  616. * **tip**: 键盘高度发生变化,keyboardheightchange 事件可能会多次触发,开发者对于相同的 height 值应该忽略掉
  617. *
  618. * 最低基础库: `2.7.0`
  619. */
  620. type InputKeyboardHeightChange<
  621. Mark extends IAnyObject = IAnyObject,
  622. TargetDataset extends IAnyObject = IAnyObject
  623. > = CustomEvent<
  624. {
  625. /** 键盘高度 */
  626. height: number
  627. duration: number
  628. },
  629. Mark,
  630. TargetDataset
  631. >
  632. /**
  633. * 取消选择时触发
  634. *
  635. * 最低基础库: 1.9.90
  636. */
  637. type PickerCancel<
  638. Mark extends IAnyObject = IAnyObject,
  639. TargetDataset extends IAnyObject = IAnyObject
  640. > = CustomEvent<never, Mark, TargetDataset>
  641. /**
  642. * value 改变时触发 change 事件
  643. *
  644. * event.detail = {value}
  645. *
  646. * 当 mode = region 时 (最低基础库: 1.4.0)
  647. *
  648. * value 改变时触发 change 事件,event.detail = {value, code, postcode},其中字段 code 是统计用区划代码,postcode 是邮政编码
  649. */
  650. type PickerChange<
  651. Mark extends IAnyObject = IAnyObject,
  652. TargetDataset extends IAnyObject = IAnyObject
  653. > = CustomEvent<
  654. {
  655. /**
  656. * 当 mode = selector 时, 返回当前选择的 value
  657. *
  658. * 当 mode = multiSelector 时, 返回一个索引数组
  659. *
  660. * 当 mode = time | date 时, 返回 `"12:01"` | `"2016-09-01"`
  661. *
  662. * 当 mode = region 时, 返回 `["广东省", "广州市", "海珠区"]`
  663. */
  664. value: string | number[] | [string, string, string]
  665. /** 统计用区划代码 当 mode = region 时有效 (最低基础库: 1.4.0) */
  666. code: [string, string, string]
  667. /** 邮政编码 当 mode = region 时有效 (最低基础库: 1.4.0) */
  668. postcode: string
  669. },
  670. Mark,
  671. TargetDataset
  672. >
  673. /** 列改变时触发 当 `mode = multiSelector` 时有效 */
  674. type PickerColumnChange<
  675. Mark extends IAnyObject = IAnyObject,
  676. TargetDataset extends IAnyObject = IAnyObject
  677. > = CustomEvent<
  678. {
  679. /** 修改的列 */
  680. column: number
  681. value: number
  682. },
  683. Mark,
  684. TargetDataset
  685. >
  686. /**
  687. * 滚动选择时触发 change 事件
  688. *
  689. * event.detail = {value}
  690. */
  691. type PickerViewChange<
  692. Mark extends IAnyObject = IAnyObject,
  693. TargetDataset extends IAnyObject = IAnyObject
  694. > = CustomEvent<
  695. {
  696. /** value 为数组,表示 picker-view 内的 picker-view-column 当前选择的是第几项 (下标从 0 开始) */
  697. value: number[]
  698. },
  699. Mark,
  700. TargetDataset
  701. >
  702. /**
  703. * 当滚动选择开始时候触发事件
  704. *
  705. * 最低基础库: 2.3.1
  706. */
  707. type PickerViewPickStart<
  708. Mark extends IAnyObject = IAnyObject,
  709. TargetDataset extends IAnyObject = IAnyObject
  710. > = CustomEvent<never, Mark, TargetDataset>
  711. /**
  712. * 当滚动选择结束时候触发事件
  713. *
  714. * 最低基础库: 2.3.1
  715. */
  716. type PickerViewPickEnd<
  717. Mark extends IAnyObject = IAnyObject,
  718. TargetDataset extends IAnyObject = IAnyObject
  719. > = CustomEvent<never, Mark, TargetDataset>
  720. /** radio-group 切换事件 */
  721. type RadioGroupChange<
  722. Mark extends IAnyObject = IAnyObject,
  723. TargetDataset extends IAnyObject = IAnyObject
  724. > = CustomEvent<
  725. /** radio-group 中选中项的 value */
  726. {
  727. value: string
  728. },
  729. Mark,
  730. TargetDataset
  731. >
  732. /**
  733. * 完成一次拖动后触发的事件
  734. *
  735. * event.detail = {value}
  736. */
  737. type SliderChange<
  738. Mark extends IAnyObject = IAnyObject,
  739. TargetDataset extends IAnyObject = IAnyObject
  740. > = CustomEvent<
  741. {
  742. /** slider 的数值 0 - 100 */
  743. value: number
  744. },
  745. Mark,
  746. TargetDataset
  747. >
  748. /**
  749. * 拖动过程中触发的事件
  750. *
  751. * event.detail = {value}
  752. *
  753. * 最低基础库: 1.7.0
  754. */
  755. type SliderChanging<
  756. Mark extends IAnyObject = IAnyObject,
  757. TargetDataset extends IAnyObject = IAnyObject
  758. > = SliderChange<Mark, TargetDataset>
  759. /**
  760. * checked 改变时触发 change 事件
  761. *
  762. * event.detail={ value}
  763. */
  764. type SwitchChange<
  765. Mark extends IAnyObject = IAnyObject,
  766. TargetDataset extends IAnyObject = IAnyObject
  767. > = CustomEvent<
  768. {
  769. value: boolean
  770. },
  771. Mark,
  772. TargetDataset
  773. >
  774. /**
  775. * 输入框聚焦时触发
  776. *
  777. * event.detail = { value, height },height 为键盘高度
  778. *
  779. * 在基础库 1.9.90 起支持
  780. */
  781. type TextareaFocus<
  782. Mark extends IAnyObject = IAnyObject,
  783. TargetDataset extends IAnyObject = IAnyObject
  784. > = InputFocus<Mark, TargetDataset>
  785. /**
  786. * 输入框失去焦点时触发
  787. *
  788. * event.detail = {value, cursor}
  789. *
  790. * **tip**: textarea 的 blur 事件会晚于页面上的 tap 事件,如果需要在 button 的点击事件获取 textarea,可以使用 form 的 bindsubmit。
  791. */
  792. type TextareaBlur<
  793. Mark extends IAnyObject = IAnyObject,
  794. TargetDataset extends IAnyObject = IAnyObject
  795. > = InputBlur<Mark, TargetDataset>
  796. /**
  797. * 输入框行数变化时调用
  798. *
  799. * event.detail = {height: 0, heightRpx: 0, lineCount: 0}
  800. */
  801. type TextareaLineChange<
  802. Mark extends IAnyObject = IAnyObject,
  803. TargetDataset extends IAnyObject = IAnyObject
  804. > = CustomEvent<
  805. {
  806. /** 输入框高度(px) */
  807. height: number
  808. /** 输入框高度(rpx) */
  809. heightRpx: number
  810. /** 行数 */
  811. lineCount: number
  812. /** 行高 */
  813. lineHeight: number
  814. },
  815. Mark,
  816. TargetDataset
  817. >
  818. /**
  819. * 当键盘输入时,触发 input 事件
  820. *
  821. * event.detail = {value, cursor, keyCode}
  822. *
  823. * keyCode 为键值,目前工具还不支持返回 keyCode 参数。
  824. *
  825. * **tip**: 不建议在多行文本上对用户的输入进行修改,所以 **bindinput 处理函数的返回值并不会反映到 textarea 上**
  826. */
  827. type TextareaInput<
  828. Mark extends IAnyObject = IAnyObject,
  829. TargetDataset extends IAnyObject = IAnyObject
  830. > = Input<Mark, TargetDataset>
  831. /**
  832. * 点击完成时, 触发 confirm 事件
  833. *
  834. * event.detail = {value: value}
  835. */
  836. type TextareaConfirm<
  837. Mark extends IAnyObject = IAnyObject,
  838. TargetDataset extends IAnyObject = IAnyObject
  839. > = InputConfirm<Mark, TargetDataset>
  840. /**
  841. * 键盘高度发生变化的时候触发此事件
  842. *
  843. * event.detail = {height: height, duration: duration}
  844. *
  845. * **tip**: 键盘高度发生变化,keyboardheightchange事件可能会多次触发,开发者对于相同的height值应该忽略掉
  846. *
  847. * 最低基础库: 2.7.0
  848. */
  849. type TextareaKeyboardHeightChange<
  850. Mark extends IAnyObject = IAnyObject,
  851. TargetDataset extends IAnyObject = IAnyObject
  852. > = InputKeyboardHeightChange<Mark, TargetDataset>
  853. /**
  854. * 功能页返回,且操作成功时触发, detail 格式与具体功能页相关
  855. *
  856. * 最低基础库: 2.1.0
  857. */
  858. type FunctionalNavigatorSuccess<
  859. Detail extends IAnyObject = IAnyObject
  860. > = CustomEvent<Detail, never, never>
  861. /**
  862. * 功能页返回,且操作失败时触发, detail 格式与具体功能页相关
  863. *
  864. * 最低基础库: 2.1.0
  865. */
  866. type FunctionalNavigatorFail<
  867. Detail extends IAnyObject = IAnyObject
  868. > = CustomEvent<Detail, never, never>
  869. /**
  870. * 当 `target="miniProgram"` 时有效,跳转小程序成功
  871. *
  872. * 最低基础库: 2.0.7
  873. */
  874. type NavigatorSuccess = CustomEvent
  875. /**
  876. * 当 `target="miniProgram"` 时有效,跳转小程序失败
  877. *
  878. * `tips`: 需要用户确认跳转 从 2.3.0 版本开始,在跳转至其他小程序前,将统一增加弹窗,询问是否跳转,用户确认后才可以跳转其他小程序。如果用户点击取消,则回调 fail cancel。
  879. *
  880. * 最低基础库: 2.0.7
  881. */
  882. type NavigatorFail = CustomEvent
  883. /**
  884. * 当 `target="miniProgram"` 时有效,跳转小程序完成
  885. *
  886. * 最低基础库: 2.0.7
  887. */
  888. type NavigatorComplete = CustomEvent
  889. /**
  890. * 当发生错误时触发 error 事件
  891. *
  892. * detail = {errMsg:MediaError.code}
  893. */
  894. type AudioError = CustomEvent<{
  895. /**
  896. * MediaError.code
  897. *
  898. * - 1 获取资源被用户禁止
  899. * - 2 网络错误
  900. * - 3 解码错误
  901. * - 4 不合适资源
  902. */
  903. errMsg: 1 | 2 | 3 | 4
  904. }>
  905. /** 当开始/继续播放时触发play事件 */
  906. type AudioPlay = CustomEvent
  907. /** 当暂停播放时触发 pause 事件 */
  908. type AudioPause = CustomEvent
  909. /**
  910. * 当播放进度改变时触发 timeupdate 事件
  911. *
  912. * detail = {currentTime, duration}
  913. */
  914. type AudioTimeUpdate = CustomEvent<{
  915. currentTime: number
  916. duration: number
  917. }>
  918. /** 当播放到末尾时触发 ended 事件 */
  919. type AudioEnded = CustomEvent
  920. /** 摄像头在非正常终止时触发,如退出后台等情况 */
  921. type CameraStop = CustomEvent
  922. /** 用户不允许使用摄像头时触发 */
  923. type CameraError = CustomEvent
  924. /**
  925. * 相机初始化完成时触发
  926. *
  927. * 最低基础库: 2.7.0
  928. */
  929. type CameraInitDone = CustomEvent
  930. /**
  931. * 在扫码识别成功时触发,仅在 mode="scanCode" 时生效
  932. *
  933. * 最低基础库: 2.1.0
  934. */
  935. type CameraScanCode = CustomEvent
  936. /** 当错误发生时触发,event.detail = {errMsg} */
  937. type ImageError = CoverImageError
  938. /** 当图片载入完毕时触发,event.detail = {height, width} */
  939. type ImageLoad = CoverImageLoad
  940. /**
  941. * 播放状态变化事件,detail = {code}
  942. *
  943. * 最低基础库 1.7.0
  944. */
  945. type LivePlayerStateChange = CustomEvent<{
  946. /**
  947. * 状态码
  948. *
  949. * - `2001` 已经连接服务器
  950. * - `2002` 已经连接服务器,开始拉流
  951. * - `2003` 网络接收到首个视频数据包(IDR)
  952. * - `2004` 视频播放开始
  953. * - `2005` 视频播放进度
  954. * - `2006` 视频播放结束
  955. * - `2007` 视频播放Loading
  956. * - `2008` 解码器启动
  957. * - `2009` 视频分辨率改变
  958. * - `-2301` 网络断连,且经多次重连抢救无效,更多重试请自行重启播放
  959. * - `-2302` 获取加速拉流地址失败
  960. * - `2101` 当前视频帧解码失败
  961. * - `2102` 当前音频帧解码失败
  962. * - `2103` 网络断连, 已启动自动重连
  963. * - `2104` 网络来包不稳: 可能是下行带宽不足,或由于主播端出流不均匀
  964. * - `2105` 当前视频播放出现卡顿
  965. * - `2106` 硬解启动失败,采用软解
  966. * - `2107` 当前视频帧不连续,可能丢帧
  967. * - `2108` 当前流硬解第一个I帧失败,SDK自动切软解
  968. * - `3001` RTMP -DNS解析失败
  969. * - `3002` RTMP服务器连接失败
  970. * - `3003` RTMP服务器握手失败
  971. * - `3005` RTMP 读/写失败
  972. */
  973. code: number
  974. }>
  975. /**
  976. * 全屏变化事件,detail = {direction, fullScreen}
  977. *
  978. * 最低基础库 1.7.0
  979. */
  980. type LivePlayerFullScreenChange = CustomEvent<{
  981. direction: 'vertical' | 'horizontal'
  982. fullScreen: boolean
  983. }>
  984. /**
  985. * 网络状态通知,detail = {info}
  986. *
  987. * 最低基础库 1.9.0
  988. */
  989. type LivePlayerNetStatus = CustomEvent<{
  990. /**
  991. * 网络状态数据
  992. *
  993. *
  994. * - `videoBitrate` 当前视频编/码器输出的比特率,单位 kbps
  995. * - `audioBitrate` 当前音频编/码器输出的比特率,单位 kbps
  996. * - `videoFPS` 当前视频帧率
  997. * - `videoGOP` 当前视频 GOP,也就是每两个关键帧(I帧)间隔时长,单位 s
  998. * - `netSpeed` 当前的发送/接收速度
  999. * - `netJitter` 网络抖动情况,抖动越大,网络越不稳定
  1000. * - `videoWidth` 视频画面的宽度
  1001. * - `videoHeight` 视频画面的高度
  1002. */
  1003. info:
  1004. | 'videoBitrate'
  1005. | 'audioBitrate'
  1006. | 'videoFPS'
  1007. | 'videoGOP'
  1008. | 'netSpeed'
  1009. | 'netJitter'
  1010. | 'videoWidth'
  1011. | 'videoHeight'
  1012. }>
  1013. /**
  1014. * 状态变化事件,detail = {code}
  1015. *
  1016. * 最低基础库: 1.7.0
  1017. */
  1018. type LivePusherStateChange = CustomEvent<{
  1019. /**
  1020. * 状态码
  1021. *
  1022. * - `1001` 已经连接推流服务器
  1023. * - `1002` 已经与服务器握手完毕,开始推流
  1024. * - `1003` 打开摄像头成功
  1025. * - `1004` 录屏启动成功
  1026. * - `1005` 推流动态调整分辨率
  1027. * - `1006` 推流动态调整码率
  1028. * - `1007` 首帧画面采集完成
  1029. * - `1008` 编码器启动
  1030. * - `-1301` 打开摄像头失败
  1031. * - `-1302` 打开麦克风失败
  1032. * - `-1303` 视频编码失败
  1033. * - `-1304` 音频编码失败
  1034. * - `-1305` 不支持的视频分辨率
  1035. * - `-1306` 不支持的音频采样率
  1036. * - `-1307` 网络断连,且经多次重连抢救无效,更多重试请自行重启推流
  1037. * - `-1308` 开始录屏失败,可能是被用户拒绝
  1038. * - `-1309` 录屏失败,不支持的Android系统版本,需要5.0以上的系统
  1039. * - `-1310` 录屏被其他应用打断了
  1040. * - `-1311` Android Mic打开成功,但是录不到音频数据
  1041. * - `-1312` 录屏动态切横竖屏失败
  1042. * - `1101` 网络状况不佳: 上行带宽太小,上传数据受阻
  1043. * - `1102` 网络断连, 已启动自动重连
  1044. * - `1103` 硬编码启动失败,采用软编码
  1045. * - `1104` 视频编码失败
  1046. * - `1105` 新美颜软编码启动失败,采用老的软编码
  1047. * - `1106` 新美颜软编码启动失败,采用老的软编码
  1048. * - `3001` RTMP -DNS解析失败
  1049. * - `3002` RTMP服务器连接失败
  1050. * - `3003` RTMP服务器握手失败
  1051. * - `3004` RTMP服务器主动断开,请检查推流地址的合法性或防盗链有效期
  1052. * - `3005` RTMP 读/写失败
  1053. */
  1054. code: number
  1055. }>
  1056. /**
  1057. * 网络状态通知,detail = {info}
  1058. *
  1059. * 最低基础库: 1.9.0
  1060. */
  1061. type LivePusherNetStatus = CustomEvent<{
  1062. /**
  1063. * 网络状态数据
  1064. *
  1065. * -`videoBitrate` 当前视频编/码器输出的比特率,单位 kbps
  1066. * -`audioBitrate` 当前音频编/码器输出的比特率,单位 kbps
  1067. * -`videoFPS` 当前视频帧率
  1068. * -`videoGOP` 当前视频 GOP,也就是每两个关键帧(I帧)间隔时长,单位 s
  1069. * -`netSpeed` 当前的发送/接收速度
  1070. * -`netJitter` 网络抖动情况,抖动越大,网络越不稳定
  1071. * -`videoWidth` 视频画面的宽度
  1072. * -`videoHeight` 视频画面的高度
  1073. */
  1074. info:
  1075. | 'videoBitrate'
  1076. | 'audioBitrate'
  1077. | 'videoFPS'
  1078. | 'videoGOP'
  1079. | 'netSpeed'
  1080. | 'netJitter'
  1081. | 'videoWidth'
  1082. | 'videoHeight'
  1083. }>
  1084. /**
  1085. * 渲染错误事件,detail = {errMsg, errCode}
  1086. *
  1087. * `tip`: 开发者工具上暂不支持 live-pusher
  1088. *
  1089. * 最低基础库: 1.7.4
  1090. */
  1091. type LivePusherError = CustomEvent<{
  1092. errMsg: string
  1093. /**
  1094. * 错误码
  1095. *
  1096. * - `10001` 用户禁止使用摄像头
  1097. * - `10002` 用户禁止使用录音
  1098. * - `10003` 背景音资源 (BGM) 加载失败
  1099. * - `10004` 等待画面资源 (waiting-image) 加载失败
  1100. */
  1101. errCode: number
  1102. }>
  1103. /**
  1104. * 背景音开始播放时触发
  1105. *
  1106. * 最低基础库: 2.4.0
  1107. */
  1108. type LivePusherBgmStart = CustomEvent
  1109. /**
  1110. * 背景音进度变化时触发,detail = {progress, duration}
  1111. *
  1112. * 最低基础库: 2.4.0
  1113. */
  1114. type LivePusherBgmProgress = CustomEvent<{
  1115. progress: number
  1116. duration: number
  1117. }>
  1118. /**
  1119. * 背景音播放完成时触发
  1120. *
  1121. * 最低基础库: 2.4.0
  1122. */
  1123. type LivePusherBgmComplete = CustomEvent
  1124. /** 当开始/继续播放时触发play事件 */
  1125. type VideoPlay = CustomEvent
  1126. /** 当暂停播放时触发 pause 事件 */
  1127. type VideoPause = CustomEvent
  1128. /** 当播放到末尾时触发 ended 事件 */
  1129. type VideoEnded = CustomEvent
  1130. /** 播放进度变化时触发,event.detail = {currentTime, duration} 。触发频率 250ms 一次 */
  1131. type VideoTimeUpdate = CustomEvent<{
  1132. currentTime: number
  1133. duration: number
  1134. }>
  1135. /**
  1136. * 视频进入和退出全屏时触发,event.detail = {fullScreen, direction}
  1137. *
  1138. * 最低基础库: 1.4.0
  1139. */
  1140. type VideoFullScreenChange = CustomEvent<{
  1141. fullScreen: boolean
  1142. direction: 'vertical' | 'horizontal'
  1143. }>
  1144. /**
  1145. * 视频出现缓冲时触发
  1146. *
  1147. * 最低基础库: 1.7.0
  1148. */
  1149. type VideoWaiting = CustomEvent
  1150. /**
  1151. * 视频播放出错时触发
  1152. *
  1153. * 最低基础库: 1.7.0
  1154. */
  1155. type VideoError = CustomEvent
  1156. /**
  1157. * 加载进度变化时触发,只支持一段加载。
  1158. *
  1159. * 最低基础库: 2.4.0
  1160. */
  1161. type VideoPregress = CustomEvent<{
  1162. /** 百分比 */
  1163. buffered: number
  1164. }>
  1165. /**
  1166. * 加载进度变化时触发,只支持一段加载。
  1167. *
  1168. * 最低基础库: 2.4.0
  1169. */
  1170. type VoipRoomError = CustomEvent
  1171. /**
  1172. * 点击地图时触发
  1173. *
  1174. * 2.9.0 起返回经纬度信息
  1175. */
  1176. type MapTap = CustomEvent<{
  1177. /** 经度,最低基础库 2.9.0 */
  1178. longitude: number
  1179. /** 纬度,最低基础库 2.9.0 */
  1180. latitude: number
  1181. }>
  1182. /**
  1183. * 点击标记点时触发
  1184. *
  1185. * e.detail = {markerId}
  1186. */
  1187. type MarkerTap = CustomEvent<{
  1188. /** 标记点 ID */
  1189. markerId: number
  1190. }>
  1191. /**
  1192. * 点击 label 时触发
  1193. *
  1194. * e.detail = {markerId}
  1195. *
  1196. * 最低基础库: 2.9.0
  1197. */
  1198. type LabelTap = MarkerTap
  1199. /**
  1200. * 点击控件时触发
  1201. *
  1202. * e.detail = {controlId}
  1203. */
  1204. type ControlTap = CustomEvent<{
  1205. /** 控件 ID */
  1206. controlId: number
  1207. }>
  1208. /**
  1209. * 点击 label 时触发
  1210. *
  1211. * e.detail = {markerId}
  1212. *
  1213. * 最低基础库: 1.2.0
  1214. */
  1215. type CalloutTap = MarkerTap
  1216. /**
  1217. * 在地图渲染更新完成时触发
  1218. *
  1219. * 最低基础库: 1.6.0
  1220. */
  1221. type MapUpdated = CustomEvent
  1222. /**
  1223. * 在地图渲染更新完成时触发
  1224. *
  1225. * 最低基础库: 1.6.0
  1226. */
  1227. type RegionChange = CustomEvent<{
  1228. /** 旋转程度,最低基础库 2.3.0 */
  1229. rotate: number
  1230. /** 缩放程度,最低基础库 2.3.0 */
  1231. skew: number
  1232. }> &
  1233. (
  1234. | {
  1235. /**
  1236. * 视野变化开始、结束时触发
  1237. *
  1238. * 视野变化开始为 `begin`
  1239. */
  1240. type: 'begin'
  1241. /**
  1242. * 导致视野变化的原因
  1243. *
  1244. * - gesture: 用户手势
  1245. * - update: 调用接口导致
  1246. */
  1247. causedBy: 'gesture' | 'update'
  1248. }
  1249. | {
  1250. /**
  1251. * 视野变化结束时触发
  1252. *
  1253. * 视野变化结束为 `end`
  1254. */
  1255. type: 'end'
  1256. /**
  1257. * 导致视野变化的原因
  1258. *
  1259. * - drag: 拖动地图导致
  1260. * - scale: 缩放导致
  1261. * - update: 调用接口导致
  1262. */
  1263. causedBy: 'drag' | 'scale' | 'update'
  1264. }
  1265. )
  1266. /**
  1267. * 广告加载成功的回调
  1268. *
  1269. * 最低基础库: 2.2.1
  1270. */
  1271. type AdLoad = CustomEvent
  1272. /**
  1273. * 广告加载失败的回调,event.detail = {errCode: 1002}
  1274. *
  1275. * `tip`: 监听到error回调后,开发者可以针对性的处理,比如隐藏广告组件的父容器,以保证用户体验,但不要移除广告组件,否则将无法收到bindload的回调。
  1276. *
  1277. * 最低基础库: 2.2.1
  1278. */
  1279. type AdError = CustomEvent<{
  1280. /**
  1281. * 错误码
  1282. *
  1283. * - `1000` 后端错误调用失败 该项错误不是开发者的异常情况 一般情况下忽略一段时间即可恢复。
  1284. * - `1001` 参数错误 使用方法错误 可以前往developers.weixin.qq.com 确认具体教程 (小程序和小游戏分别有各自的教程,可以在顶部选项中,“设计”一栏的右侧进行切换)。
  1285. * - `1002` 广告单元无效 可能是拼写错误、或者误用了其他APP的广告ID 请重新前往mp.weixin.qq.com确认广告位ID。
  1286. * - `1003` 内部错误 该项错误不是开发者的异常情况 一般情况下忽略一段时间即可恢复。
  1287. * - `1004` 无适合的广告 广告不是每一次都会出现,这次没有出现可能是由于该用户不适合浏览广告 属于正常情况,且开发者需要针对这种情况做形态上的兼容。
  1288. * - `1005` 广告组件审核中 你的广告正在被审核,无法展现广告 请前往mp.weixin.qq.com确认审核状态,且开发者需要针对这种情况做形态上的兼容。
  1289. * - `1006` 广告组件被驳回 你的广告审核失败,无法展现广告 请前往mp.weixin.qq.com确认审核状态,且开发者需要针对这种情况做形态上的兼容。
  1290. * - `1007` 广告组件被驳回 你的广告能力已经被封禁,封禁期间无法展现广告 请前往mp.weixin.qq.com确认小程序广告封禁状态。
  1291. * - `1008` 广告单元已关闭 该广告位的广告能力已经被关闭 请前往mp.weixin.qq.com重新打开对应广告位的展现。
  1292. */
  1293. errCode: number
  1294. }>
  1295. /**
  1296. * 广告关闭的回调
  1297. *
  1298. * 最低基础库: 2.6.5
  1299. */
  1300. type AdClose = CustomEvent
  1301. /**
  1302. * 网页向小程序 postMessage 时,会在特定时机 (小程序后退、组件销毁、分享) 触发并收到消息。e.detail = { data }
  1303. *
  1304. * 最低基础库: 1.6.4
  1305. */
  1306. type WebviewMessage = CustomEvent<{
  1307. /** 多次 postMessage 的参数组成的数组 */
  1308. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  1309. data: any[]
  1310. }>
  1311. /**
  1312. * 网页加载成功时候触发此事件。e.detail = { src }
  1313. *
  1314. * 最低基础库: 1.6.4
  1315. */
  1316. type WebviewLoad = CustomEvent<{
  1317. src: string
  1318. }>
  1319. /**
  1320. * 网页加载失败的时候触发此事件。e.detail = { src }
  1321. *
  1322. * 最低基础库: 1.6.4
  1323. */
  1324. type WebviewError = CustomEvent<{
  1325. src: string
  1326. }>
  1327. }