当前位置:   article > 正文

js/uniapp的global对象_uniapp 全局对象

uniapp 全局对象

借鉴:https://blog.csdn.net/chenchunlin526/article/details/78908592

在这里插入图片描述

js的global对象是ECMAScript的高级对象,在浏览器里是windows对象,虽然查找时都说不可访问,但是亲测是可以直接访问的

比如下面有在h5、小程序、app上的global打印,总的来说,都是一个全局的对象,可以向里面添加新的全局方法,但是在uniapp里用globalData就够了,就用不上这个了

比如:
在uniapp的h5编译时:
在这里插入图片描述
在这里插入图片描述

在小程序里编译时:
在这里插入图片描述
编译为App时:

{
   "__updateComponentData":"function() { [native code] }","clearNativeTimeout":"function() { [native code] }","setNativeTimeout":"function() { [native code] }","setNativeInterval":"function() { [native code] }","callT3DLinkNative":"function() { [native code] }","callGCanvasLinkNative":"function() { [native code] }","btoa":"function() { [native code] }","clearNativeInterval":"function() { [native code] }","atob":"function() { [native code] }","nativeLog":"function() { [native code] }","WXEnvironment":{
   "enableBackupThread":"false","debugMode":"true","scale":"2.75","androidStatusBarHeight":"75.0","appName":"io.dcloud.HBuilder","deviceModel":"MI CC 9","__enable_native_promise__":"true","weexVersion":"0.28.0","osName":"android","appVersion":"13.2.3","deviceWidth":"1080","osVersion":"11","deviceHeight":"2221","layoutDirection":"ltr","os":"android","cacheDir":"/data/user/0/io.dcloud.HBuilder/cache","platform":"android"},"service":{
   },"BroadcastChannel":"function() { [native code] }","WeexPlus":"function() { [native code] }","__uniConfig":{
   "pages":["pages/login/login"],"window":{
   "navigationBarTextStyle":"black","navigationBarTitleText":"uni-app","enablePullDownRefresh":true,"navigationBarBackgroundColor":"#F8F8F8","backgroundColor":"#F8F8F8","navigationStyle":"custom","titleNView":true},"tabBar":{
   "color":"#7A7E83","selectedColor":"#04BFBF","borderStyle":"black","backgroundColor":"#ffffff","list":[{
   "pagePath":"pages/index/index","iconPath":"static/tabBar-icon/index_f.png","selectedIconPath":"static/tabBar-icon/index_t.png","text":"首页"},{
   "pagePath":"pages/report/report","iconPath":"static/tabBar-icon/report_f.png","selectedIconPath":"static/tabBar-icon/report_t.png","text":"报告"},{
   "pagePath":"pages/commodity/commodity","iconPath":"static/tabBar-icon/commodity_f.png","selectedIconPath":"static/tabBar-icon/commodity_t.png","text":"购买"},{
   "pagePath":"pages/user/user","iconPath":"static/tabBar-icon/user_f.png","selectedIconPath":"static/tabBar-icon/user_t.png","text":"ebugMode":"true","deviceHeight":"2221","deviceModel":"MI CC 9","deviceWidth":"1080","enableBackupThread":"false","layoutDirection":"ltr","libIcuPath":"/apex/com.android.i18n/etc/icu/icudt66l.dat","libJscPath":"","libJssPath":"/data/app/~~l7dLkggKR4GeT62BIy3SUA==/io.dcloud.HBuilder-V2JdCUun-WNEY1PC3JwPng==/lib/arm/libweexjss.so","libLdPath":"/data/app/~~l7dLkggKR4GeT62BIy3SUA==/io.dcloud.HBuilder-V2JdCUun-WNEY1PC3JwPng==/lib/arm:/data/app/~~l7dLkggKR4GeT62BIy3SUA==/io.dcloud.HBuilder-V2JdCUun-WNEY1PC3JwPng==/base.apk!/lib/armeabi-v7a","logLevel":"info","needInitV8":"1","options":{
   "__enable_native_promise__":"true","androidStatusBarHeight":"75.0","debugMode":"true","enableBackupThread":"false","os":"android","osName":"android","scale":"2.75"},"os":"android","osName":"android","osVersion":"11","platform":"android","scale":"2.75","useRunTimeApi":false,"useSingleProcess":"false","weexVersion":"0.28.0"},"plus_appid":"HBuilder","plus_web_id":"__uniapp__service","plus_weex_id":"__uniapp__service"},"_nativeData":{
   "Plus_InitURL":"_www/app-service.js"},"document":{
   "id":"1","URL":"file:///storage/emulated/0/Android/data/io.dcloud.HBuilder/apps/HBuilder/www/app-service.js","nodeMap":{
   "_documentElement":{
   "ref":"_documentElement","type":"document","attr":{
   },"style":{
   }}},"listener":{
   "id":"1","batched":false,"updates":[],"handler":"function() { [native code] }"},"taskCenter":{
   "instanceId":"1","callbackManager":{
   "instanceId":"1","lastCallbackId":13,"callbacks":{
   "1":"function() { [native code] }","2":"function() { [native code] }","3":"function() { [native code] }","4":"function() { [native code] }","5":"function() { [native code] }","6":"function() { [native code] }","7":"function() { [native code] }","8":"function() { [native code] }","9":"function() { [native code] }","10":"function() { [native code] }","11":"function() { [native code] }","12":"function() { [native code] }","13":"function() { [native code] }"},"hooks":{
   }}},"documentElement":{
   "ref":"_documentElement","type":"document","attr":{
   },"style":{
   }},"__$automator__":false,"__$compiler__":"uni-app","__$styleCompiler__":"weex"},"requireModule":"function() { [native code] }","importScript":"function() { [native code] }","isRegisteredModule":"function() { [native code] }","isRegisteredComponent":"function() { [native code] }"},"getJSFMVersion":"function() { [native code] }","requireModule":"function() { [native code] }","__WEEX_CALL_JAVASCRIPT__":"function() { [native code] }","services":{
   "service":{
   },"BroadcastChannel":"function() { [native code] }","WeexPlus":"function() { [native code] }","__uniConfig":{
   "pages":["pages/login/login"],"window":{
   "navigationBarTextStyle":"black","navigationBarTitleText":"uni-app","enablePullDownRefresh":true,"navigationBarBackgroundColor":"#F8F8F8","backgroundColor":"#F8F8F8","navigationStyle":"custom","titleNView":true},"tabBar":{
   "color":"#7A7E83","selectedColor":"#04BFBF","borderStyle":"black","backgroundColor":"#ffffff","list":[{
   "pagePath":"pages/index/index","iconPath":"static/tabBar-icon/index_f.png","selectedIconPath":"static/tabBar-icon/index_t.png","text":"首页"},{
   "pagePath":"pages/report/report","iconPath":"static/tabBar-icon/report_f.png","selectedIconPath":"static/tabBar-icon/report_t.png","text":"报告"},{
   "pagePath":"pages/commodity/commodity","iconPath":"static/tabBar-icon/commodity_f.png","selectedIconPath":"static/tabBar-icon/commodity_t.png","text":"购买"},{
   "pagePath":"pages/user/user","iconPath":"static/tabBar-icon/user_f.png","selectedIconPath":"static/tabBar-icon/user_t.png","text":"我的"}],"selected":0},"nvueCompiler":"uni-app","nvueStyleCompiler":"weex","renderer":"auto","splashscreen":{
   "alwaysShowBeforeRender":false,"autoclose":false},"appname":"检康","compilerVersion":"3.1.22","entryPagePath":"pages/login/login","networkTimeout":{
   "request":60000,"connectSocket":60000,"uploadFile":60000,"downloadFile":60000},"onReady":"function() { [native code] }","onServiceReady":"function() { [native code] }","viewport":393,"defaultFontSize":20},"__uniRoutes":["/apex/com.android.i18n/etc/icu/icudt66l.dat","libJscPath":"","libJssPath":"/data/app/~~l7dLkggKR4GeT62BIy3SUA==/io.dcloud.HBuilder-V2JdCUun-WNEY1PC3JwPng==/lib/arm/libweexjss.so","libLdPath":"/data/app/~~l7dLkggKR4GeT62BIy3SUA==/io.dcloud.HBuilder-V2JdCUun-WNEY1PC3JwPng==/lib/arm:/data/app/~~l7dLkggKR4GeT62BIy3SUA==/io.dcloud.HBuilder-V2JdCUun-WNEY1PC3JwPng==/base.apk!/lib/armeabi-v7a","logLevel":"info","needInitV8":"1","options":{
   "__enable_native_promise__":"true","androidStatusBarHeight":"75.0","debugMode":"true","enableBackupThread":"false","os":"android","osName":"android","scale":"2.75"},"os":"android","osName":"android","osVersion":"11","platform":"android","scale":"2.75","useRunTimeApi":false,"useSingleProcess":"false","weexVersion":"0.28.0"},"plus_appid":"HBuilder","plus_web_id":"__uniapp__service","plus_weex_id":"__uniapp__service"},"_nativeData":{
   "Plus_InitURL":"_www/app-service.js"},"document":{
   "id":"1","URL":"file:///storage/emulated/0/Android/data/io.dcloud.HBuilder/apps/HBuilder/www/app-service.js","nodeMap":{
   "_documentElement":{
   "ref":"_documentElement","type":"document","attr":{
   },"style":{
   }}},"listener":{
   "id":"1","batched":false,"updates":[],"handler":"function() { [native code] }"},"taskCenter":{
   "instanceId":"1","callbackManager":{
   "instanceId":"1","lastCallbackId":13,"callbacks":{
   "1":"function() { [native code] }","2":"function() { [native code] }","3":"function() { [native code] }","4":"function() { [native code] }","5":"function() { [native code] }","6":"function() { [native code] }","7":"function() { [native code] }","8":"function() { [native code] }","9":"function() { [native code] }","10":"function() { [native code] }","11":"function() { [native code] }","12":"function() { [native code] }","13":"function() { [native code] }"},"hooks":{
   }}},"documentElement":{
   "ref":"_documentElement","type":"document","attr":{
   },"style":{
   }},"__$automator__":false,"__$compiler__":"uni-app","__$styleCompiler__":"weex"},"requireModule":"function() { [native code] }","importScript":"function() { [native code] }","isRegisteredModule":"function() { [native code] }","isRegisteredComponent":"function() { [native code] }"},"weexB
19:05:33.763 ridge":{"getLanguage":"function() {
    [native code] }","preloadReady":"function() {
    [native code] }","log":"function() {
    [native code] }","sendNativeEvent":"function() {
    [native code] }","uniReady":"function() {
    [native code] }","pushDebugData":"function() {
    [native code] }","getConfigInfo":"function() {
    [native code] }","evalJSFiles":"function() {
    [native code] }","getValue":"function() {
    [native code] }","getDotData":"function() {
    [native code] }","setDefaultFontSize":"function() {
    [native code] }","postMessage":"function() {
    [native code] }","removeAllEventListeners":"function() {
    [native code] }","execSync":"function() {
    [native code] }","getRedirectInfo":"function() {
    [native code] }","exec":"function() {
    [native code] }","addEventListener":"function() {
    [native code] }","setLanguage":"function() {
    [native code] }"},"globalEvent":{"removeEventListener":"function() {
    [native code] }","removeAllEventListeners":"function() {
    [native code] }","addEventListener":"function() {
    [native code] }"},"tools":{"__UUID__":1,"UNKNOWN":-1,"IOS":0,"ANDROID":1,"platform":1,"debug":true,"UUID":"function() {
    [native code] }","extend":"function() {
    [native code] }","typeName":"function() {
    [native code] }","isDate":"function() {
    [native code] }","isArray":"function() {
    [native code] }","isDebug":"function() {
    [native code] }","stringify":"function() {
    [native code] }","isNumber":"function() {
    [native code] }","getElementOffsetInWebview":"function() {
    [native code] }","getElementOffsetXInWebview":"function() {
    [native code] }","getElementOffsetYInWebview":"function() {
    [native code] }","execJSfile":"function() {
    [native code] }","copyObjProp2Obj":"function() {
    [native code] }","clone":"function() {
    [native code] }"},"bridge":{"NO_RESULT":0,"OK":1,"CLASS_NOT_FOUND_EXCEPTION":2,"ILLEGAL_ACCESS_EXCEPTION":3,"INSTANTIATION_EXCEPTION":4,"MALFORMED_URL_EXCEPTION":5,"IO_EXCEPTION":6,"INVALID_ACTION":7,"JSON_EXCEPTION":8,"ERROR":9,"callbacks":{},"exec":"function() {
    [native code] }","execSync2":"function() {
    [native code] }","execSync":"function() {
    [native code] }","nativeEval":"function() {
    [native code] }","callbackFromNative":"function() {
    [native code] }","callbackId":"function() {
    [native code] }"},"obj":{"Callback":"function() {
    [native code] }"},"setInterval":"function() {
    [native code] }","clearInterval":"function() {
    [native code] }","setTimeout":"function() {
    [native code] }","clearTimeout":"function() {
    [native code] }","timer":{"setInterval":"function() {
    [native code] }","clearInterval":"function() {
    [native code] }","setTimeout":"function() {
    [native code] }","clearTimeout":"function() {
    [native code] }"},"accelerometer":{"getCurrentAcceleration":"function() {
    [native code] }","watchAcceleration":"function() {
    [native code] }","clearWatch":"function() {
    [native code] }"},"audio":{"getRecorder":"function() {
    [native code] }","createPlayer":"function() {
    [native code] }","ROUTE_SPEAKER":0,"ROUTE_EARPIECE":1},"barcode":{"Barcode":"function() {
    [native code] }","create":"function() {
    [native code] }","getBarcodeById":"function() {
    [native code] }","scan":"function() {
    [native code] }","QR":0,"EAN13":1,"EAN8":2,"AZTEC":3,"DATAMATRIX":4,"UPCA":5,"UPCE":6,"CODABAR":7,"CODE39":8,"CODE93":9,"CODE128":10,"ITF":11,"MAXICODE":12,"PDF417":13,"RSS14":14,"RSSEXPANDED":15},"cache":{"clear":"function() {
    [native code] }","calculate":"function() {
    [native code] }","setMaxSize":"function() {
    [native code] }"},"camera":{"getCamera":"function() {
    [native code] }"},"contacts":{"getAddressBook":"function() {
    [native code] }","ADDRESSBOOK_PHONE":0,"ADDRESSBOOK_SIM":1},"downloader":{"__taskList__":[],"createDownload":"function() {
    [native code] }","enumerate":"function() {
    [native code] }","clear":"function() {
    [native code] }","startAll":"function() {
    [native code] }","__handlerEvt__":"function() {
    [native code] }"},"gallery":{"__galleryStatus":0,"onPickImageFinished":null,"pick":"function() {
    [native code] }","save":"function() {
    [native code] }"},"geolocation":{"lastPosition":null,"getCurrentPosition":"function() {
    [native code] }","watchPosition":"function() {
    [native code] }","clearWatch":"function() {
    [native code] }"},"io":{"FileSystem":"function() {
    [native code] }","DirectoryEntry":"function() {
    [native code] }","DirectoryReader":"function() {
    [native code] }","FileReader":"function() {
    [native code] }","FileWriter":"function() {
    [native code] }","requestFileSystem":"function() {
    [native code] }","resolveLocalFileSystemURL":"function() {
    [native code] }","convertLocalFileSystemURL":"function() {
    [native code] }","convertAbsoluteFileSystem":"function() {
    [native code] }","getImageInfo":"function() {
    [native code] }","getFileInfo":"function() {
    [native code] }","getAudioInfo":"function() {
    [native code] }","getVideoInfo":"function() {
    [native code] }","chooseFile":"function() {
    [native code] }","PRIVATE_WWW":1,"PRIVATE_DOC":2,"PUBLIC_DOCUMENTS":3,"PUBLIC_DOWNLOADS":4},"maps":{"Map":"function() {
    [native code] }","openSysMap":"function() {
    [native code] }","MapType":{"MAPTYPE_SATELLITE":"MAPTYPE_SATELLITE","MAPTYPE_NORMAL":"MAPTYPE_NORMAL"},"Marker":"function() {
    [native code] }","Bubble":"function() {
    [native code] }","Point":"function() {
    [native code] }","Bounds":"function() {
    [native code] }","Circle":"function() {
    [native code] }","Polygon":"function() {
    [native code] }","Polyline":"function() {
    [native code] }","Position":"function() {
    [native code] }","Route":"function() {
    [native code] }","Search":"function() {
    [native code] }","SearchPolicy":{"TRANSIT_TIME_FIRST":"TRANSIT_TIME_FIRST","TRANSIT_TRANSFER_FIRST":"TRANSIT_TRANSFER_FIRST","TRANSIT_WALK_FIRST":"TRANSIT_WALK_FIRST","TRANSIT_FEE_FIRST":"TRANSIT_FEE_FIRST","DRIVING_TIME_FIRST":"DRIVING_TIME_FIRST","DRIVING_NO_EXPRESSWAY":"DRIVING_NO_EXPRESSWAY","DRIVING_FEE_FIRST":"DRIVING_FEE_FIRST"},"__SearchRouteResult__":"function() {
    [native code] }","</
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/672000
推荐阅读