脚本规范校验

组件逻辑层响应页面操作的代码,需要导出以下规范的对象。

  1. {
  2. // 数据
  3. data: {
  4. dataKey1: dataValue1,
  5. dataKey2: dataValue2
  6. },
  7. // 属性
  8. props: {
  9. propKey1: propValue1,
  10. propKey2: propValue2
  11. },
  12. // 计算属性
  13. computed: {
  14. computedKey1: () => {
  15. },
  16. computedKey2: () => {
  17. }
  18. },
  19. // 监听属性
  20. watch: {
  21. watchKey1: () => {
  22. },
  23. watchKey2: () => {
  24. }
  25. },
  26. // 实例初始化之后,数据和方法挂在到实例之前
  27. beforeCreate: () => {
  28. },
  29. // 数据及方法挂载完成
  30. created: () => {
  31. },
  32. // 开始挂载已经编译完成的html,到对应的dom节点时
  33. beforeMount: () => {
  34. },
  35. // 模板或者html编译完成,且渲染到dom中完成
  36. mounted: () => {
  37. },
  38. // 实例销毁之前
  39. beforeDestroy: () => {
  40. },
  41. // 实例销毁后
  42. destroyed: () => {
  43. }
  44. }

生命周期

钩子执行时机详细
beforeCreate实例初始化之后,数据和方法挂在到实例之前在该钩子函数中会传入当前页面query参数
created数据及方法挂载完成
beforeMount开始挂载已经编译完成的html,到对应的dom节点时
mounted模板或者html编译完成,且渲染到dom中完成
beforeDestroy实例销毁之前
destroyed实例销毁后

全局变量校验

编写一端代码逻辑时,如果使用其他端的全局变量,会校验失败。

按照端类型区分可用的全局变量:

WEEX

weex, global

WX

wx, global

alipay

my, global

baidu

swan, global

WEB

postMessage, blur, focus, close, frames, self, window, parent, opener, top, length, closed, location, document, origin, name, history, locationbar, menubar, personalbar, scrollbars, statusbar, toolbar, status, frameElement, navigator, customElements, external, screen, innerWidth, innerHeight, scrollX, pageXOffset, scrollY, pageYOffset, screenX, screenY, outerWidth, outerHeight, devicePixelRatio, clientInformation, screenLeft, screenTop, defaultStatus, defaultstatus, styleMedia, onanimationend, onanimationiteration, onanimationstart, onsearch, ontransitionend, onwebkitanimationend, onwebkitanimationiteration, onwebkitanimationstart, onwebkittransitionend, isSecureContext, onabort, onblur, oncancel, oncanplay, oncanplaythrough, onchange, onclick, onclose, oncontextmenu, oncuechange, ondblclick, ondrag, ondragend, ondragenter, ondragleave, ondragover, ondragstart, ondrop, ondurationchange, onemptied, onended, onerror, onfocus, oninput, oninvalid, onkeydown, onkeypress, onkeyup, onload, onloadeddata, onloadedmetadata, onloadstart, onmousedown, onmouseenter, onmouseleave, onmousemove, onmouseout, onmouseover, onmouseup, onmousewheel, onpause, onplay, onplaying, onprogress, onratechange, onreset, onresize, onscroll, onseeked, onseeking, onselect, onstalled, onsubmit, onsuspend, ontimeupdate, ontoggle, onvolumechange, onwaiting, onwheel, onauxclick, ongotpointercapture, onlostpointercapture, onpointerdown, onpointermove, onpointerup, onpointercancel, onpointerover, onpointerout, onpointerenter, onpointerleave, onafterprint, onbeforeprint, onbeforeunload, onhashchange, onlanguagechange, onmessage, onmessageerror, onoffline, ononline, onpagehide, onpageshow, onpopstate, onrejectionhandled, onstorage, onunhandledrejection, onunload, performance, stop, open, alert, confirm, prompt, print, requestAnimationFrame, cancelAnimationFrame, requestIdleCallback, cancelIdleCallback, captureEvents, releaseEvents, getComputedStyle, matchMedia, moveTo, moveBy, resizeTo, resizeBy, getSelection, find, webkitRequestAnimationFrame, webkitCancelAnimationFrame, fetch, btoa, atob, createImageBitmap, scroll, scrollTo, scrollBy, onappinstalled, onbeforeinstallprompt, crypto, ondevicemotion, ondeviceorientation, ondeviceorientationabsolute, indexedDB, webkitStorageInfo, sessionStorage, localStorage, chrome, visualViewport, speechSynthesis, webkitRequestFileSystem, webkitResolveLocalFileSystemURL, openDatabase, applicationCache, caches, whichAnimationEvent, animationendEvent, infinity, SETTING, AppView, ExtensionOptions, ExtensionView, WebView, iconPath, app, _ZOOM, Feed, md5, $, jQuery, Search, windmill, Lethargy, alertTimeOut, supportApps, lethargyX, lethargyY, iView, onModuleResLoaded, iEditDelete, infinityDrag, i, array, TEMPORARY, PERSISTENT, addEventListener, removeEventListener, dispatchEvent