bilibili小程序
指南
组件
API
资源
FAQ
›
CanvasContext
概述
基础
bl.canIUse
bl.base64Encode
bl.base64Decode
更新
bl.getUpdateManager
UpdateManager
UpdateManager.applyUpdate
UpdateManager.onCheckForUpdate
UpdateManager.onUpdateFailed
UpdateManager.onUpdateReady
生命周期
bl.getLaunchOptions
bl.getLaunchOptionsSync
bl.getEnterOptionsSync
应用级事件
bl.onError
bl.offError
路由
bl.navigateTo
bl.navigateBack
bl.navigateToMiniProgram
bl.redirectTo
bl.switchTab
bl.reLaunch
系统
bl.getSystemInfo
bl.getSystemInfoSync
bl.getAppBaseInfo
网络
bl.request
bl.downloadFile
bl.uploadFile
bl.connectSocket
SocketTask
SocketTask.close
SocketTask.onClose
SocketTask.onError
SocketTask.onMessage
SocketTask.onOpen
SocketTask.send
界面
交互
bl.showToast
bl.hideToast
bl.showLoading
bl.hideLoading
bl.showModal
bl.showActionSheet
滚动
bl.pageScrollTo
下拉刷新
bl.startPullDownRefresh
bl.stopPullDownRefresh
导航栏
bl.setNavigationBarTitle
bl.setNavigationBarColor
bl.showNavigationLeftButton
bl.hideNavigationLeftButton
bl.setStatusBarStyle
bl.getMenuButtonBoundingClientRect
bl.setStatusBarHidden
窗口
bl.onWindowResize
bl.offWindowResize
Tab Bar
bl.setTabBarItem
bl.setTabBarStyle
bl.showTabBar
bl.hideTabBar
bl.showTabBarRedDot
bl.hideTabBarRedDot
bl.setTabBarBadge
bl.removeTabBarBadge
字体
bl.loadFontFace
背景
bl.setBackgroundColor
夜间主题
bl.onThemeChange
bl.offThemeChange
键盘
bl.onKeyboardHeightChange
bl.getSelectedTextRange
动画
bl.createAnimation
Animation
Animation.matrix
Animation.matrix3d
Animation.rotate
Animation.rotate3d
Animation.rotateX
Animation.rotateY
Animation.rotateZ
Animation.scale
Animation.scale3d
Animation.scaleX
Animation.scaleY
Animation.scaleZ
Animation.skew
Animation.skewX
Animation.skewY
Animation.translate
Animation.translate3d
Animation.translateX
Animation.translateY
Animation.translateZ
Animation.export
Animation.step
画布
bl.createCanvasContext
bl.canvasToTempFilePath
bl.canvasPutImageData
bl.canvasGetImageData
CanvasContext
CanvasContext.arc
CanvasContext.arcTo
CanvasContext.beginPath
CanvasContext.bezierCurveTo
CanvasContext.clearRect
CanvasContext.clip
CanvasContext.closePath
CanvasContext.createCircularGradient
CanvasContext.createLinearGradient
CanvasContext.createPattern
CanvasContext.draw
CanvasContext.drawImage
CanvasContext.fill
CanvasContext.fillRect
CanvasContext.fillText
CanvasContext.lineTo
CanvasContext.measureText
CanvasContext.moveTo
CanvasContext.quadraticCurveTo
CanvasContext.rect
CanvasContext.restore
CanvasContext.rotate
CanvasContext.save
CanvasContext.scale
CanvasContext.setFillStyle
CanvasContext.setFontSize
CanvasContext.setGlobalAlpha
CanvasContext.setLineCap
CanvasContext.setLineDash
CanvasContext.setLineJoin
CanvasContext.setLineWidth
CanvasContext.setMiterLimit
CanvasContext.setShadow
CanvasContext.setStrokeStyle
CanvasContext.setTextAlign
CanvasContext.setTextBaseline
CanvasContext.setTransform
CanvasContext.stroke
CanvasContext.strokeRect
CanvasContext.strokeText
CanvasContext.transform
CanvasContext.translate
CanvasGradient
CanvasGradient.addColorStop
Color
数据缓存
bl.setStorage
bl.setStorageSync
bl.getStorage
bl.getStorageSync
bl.getStorageInfo
bl.getStorageInfoSync
bl.removeStorage
bl.removeStorageSync
bl.clearStorage
bl.clearStorageSync
媒体
图片
bl.previewImage
bl.saveImageToPhotosAlbum
bl.chooseImage
音频
bl.createInnerAudioContext
bl.setInnerAudioOption
InnerAudioContext
InnerAudioContext.destroy
InnerAudioContext.offCanplay
InnerAudioContext.offEnded
InnerAudioContext.offError
InnerAudioContext.offPause
InnerAudioContext.offPlay
InnerAudioContext.offSeeked
InnerAudioContext.offSeeking
InnerAudioContext.offStop
InnerAudioContext.offTimeUpdate
InnerAudioContext.offWaiting
InnerAudioContext.onCanplay
InnerAudioContext.onEnded
InnerAudioContext.onError
InnerAudioContext.onPause
InnerAudioContext.onPlay
InnerAudioContext.onSeeked
InnerAudioContext.onSeeking
InnerAudioContext.onStop
InnerAudioContext.onTimeUpdate
InnerAudioContext.onWaiting
InnerAudioContext.pause
InnerAudioContext.play
InnerAudioContext.seek
InnerAudioContext.stop
视频
bl.saveVideoToPhotosAlbum
bl.createVideoContext
VideoContext
VideoContext.play
VideoContext.pause
VideoContext.playbackRate
VideoContext.sendDanmu
VideoContext.seek
VideoContext.stop
VideoContext.requestFullScreen
VideoContext.exitFullScreen
VideoContext.frameDataToTempFilePath
相机
bl.createCameraContext
CameraContext
CameraContext.onCameraFrame
CameraContext.setZoom
CameraContext.startRecord
CameraContext.stopRecord
CameraContext.takePhoto
CameraFrameListener
CameraFrameListener.start
CameraFrameListener.stop
SVGA 动画
bl.createSVGAContext
SVGAContext
SVGAContext.play
SVGAContext.stop
SVGAContext.pause
SVGAContext.seekToFrame
SVGAContext.seekToPercentage
SVGAContext.setVisibility
SVGAContext.setImage
SVGAContext.setText
SVGAContext.clearDynamicObjects
设备
蓝牙-通用
bl.openBluetoothAdapter
bl.closeBluetoothAdapter
bl.startBluetoothDevicesDiscovery
bl.stopBluetoothDevicesDiscovery
bl.getConnectedBluetoothDevices
bl.getBluetoothDevices
bl.getBluetoothAdapterState
bl.onBluetoothDeviceFound
bl.onBluetoothAdapterStateChange
bl.offBluetoothDeviceFound
bl.offBluetoothAdapterStateChange
bl.makeBluetoothPair
bl.isBluetoothDevicePaired
蓝牙-低功耗中心设备
bl.createBLEConnection
bl.closeBLEConnection
bl.getBLEDeviceServices
bl.getBLEDeviceCharacteristics
bl.getBLEMTU
bl.getBLEDeviceRSSI
bl.notifyBLECharacteristicValueChange
bl.readBLECharacteristicValue
bl.writeBLECharacteristicValue
bl.setBLEMTU
bl.onBLEConnectionStateChange
bl.onBLECharacteristicValueChange
bl.onBLEMTUChange
bl.offBLEConnectionStateChange
bl.offBLECharacteristicValueChange
bl.offBLEMTUChange
蓝牙-低功耗外围设备
bl.createBLEPeripheralServer
bl.onBLEPeripheralConnectionStateChanged
bl.offBLEPeripheralConnectionStateChanged
BLEPeripheralServer
BLEPeripheralServer.addService
BLEPeripheralServer.removeService
BLEPeripheralServer.startAdvertising
BLEPeripheralServer.stopAdvertising
BLEPeripheralServer.writeCharacteristicValue
BLEPeripheralServer.close
BLEPeripheralServer.onCharacteristicWriteRequest
BLEPeripheralServer.onCharacteristicReadRequest
BLEPeripheralServer.onCharacteristicSubscribed
BLEPeripheralServer.onCharacteristicUnsubscribed
BLEPeripheralServer.offCharacteristicWriteRequest
BLEPeripheralServer.offCharacteristicReadRequest
BLEPeripheralServer.offCharacteristicSubscribed
BLEPeripheralServer.offCharacteristicUnsubscribed
屏幕
bl.onUserCaptureScreen
bl.offUserCaptureScreen
设备方向
bl.startDeviceMotionListening
bl.stopDeviceMotionListening
bl.onDeviceMotionChange
bl.offDeviceMotionChange
加速计
bl.startAccelerometer
bl.stopAccelerometer
bl.onAccelerometerChange
bl.offAccelerometerChange
罗盘
bl.startCompass
bl.stopCompass
bl.onCompassChange
bl.offCompassChange
陀螺仪
bl.stopGyroscope
bl.startGyroscope
bl.onGyroscopeChange
bl.offGyroscopeChange
网络
bl.onNetworkStatusChange
bl.getNetworkType
性能
bl.onMemoryWarning
剪切板
bl.setClipboardData
bl.getClipboardData
定位
bl.getLocation
调试
bl.setEnableDebug
console
console.debug
console.error
console.info
console.log
console.warn
定时器
setTimeout
clearTimeout
setInterval
clearInterval
开放接口
bl.login
bl.getUserInfo
bl.checkSession
bl.share
bl.authorize
bl.openSetting
bl.getSetting
bl.getAccountInfo
bl.getAccountInfoSync
bl.getFollowUpperStatus
bl.chooseAddress
bl.requestPayment
bl.updateApp
人脸检测
bl.createFaceDetection
FaceDetection
FaceDetection.send
FaceDetection.onResult
FaceDetection.onError
FaceDetection.close
文件
bl.getFileSystemManager
bl.getFileSystemManagerExtra
bl.openDocument
bl.chooseFile
bl.env
FileSystemManager
FileSystemManager.access
FileSystemManager.accessSync
FileSystemManager.appendFile
FileSystemManager.appendFileSync
FileSystemManager.copyFile
FileSystemManager.copyFileSync
FileSystemManager.getFileInfo
FileSystemManager.getSavedFileList
FileSystemManager.mkdir
FileSystemManager.mkdirSync
FileSystemManager.readFile
FileSystemManager.readFileSync
FileSystemManager.readdir
FileSystemManager.readdirSync
FileSystemManager.rename
FileSystemManager.removeSavedFile
FileSystemManager.renameSync
FileSystemManager.rmdir
FileSystemManager.rmdirSync
FileSystemManager.saveFile
FileSystemManager.saveFileSync
FileSystemManager.stat
FileSystemManager.statSync
FileSystemManager.unlink
FileSystemManager.unlinkSync
FileSystemManager.unzip
FileSystemManager.writeFile
FileSystemManager.writeFileSync
DOM操作
bl.createSelectorQuery
bl.createIntersectionObserver
IntersectionObserver
IntersectionObserver
IntersectionObserver.disconnect
IntersectionObserver.observe
IntersectionObserver.relativeTo
IntersectionObserver.relativeToViewport
NodesRef
NodesRef
NodesRef.fields
NodesRef.boundingClientRect
NodesRef.scrollOffset
SelectorQuery
SelectorQuery
SelectorQuery.in
SelectorQuery.select
SelectorQuery.selectAll
SelectorQuery.selectViewport
SelectorQuery.exec
特殊能力
摇一摇
bl.startShake
bl.stopShake
bl.onShakeChange
bl.offShakeChange
CanvasContext.transform(number scaleX, number skewX, number skewY, number scaleY, number translateX, number translateY)
使用矩阵多次叠加当前变换的方法
参数
number scaleX
水平缩放
number skewX
水平倾斜
number skewY
垂直倾斜
number scaleY
垂直缩放
←
CanvasContext.strokeText
CanvasContext.translate
→
参数
number scaleX
number skewX
number skewY
number scaleY