cordova插件-Device Orientation
小編:管理員 229閱讀 2022.09.13
- 添加插件
$ cordova plugin addcordova-plugin-device-orientation

圖 13如上則插入成功
- 插件的使用
- Methods
- navigator.compass.getCurrentHeading
- navigator.compass.watchHeading
- navigator.compass.clearWatch
2. Example
var watchID; function getCurrent () { navigator.compass.getCurrentHeading(onSuccess, onError); } function onSuccess(heading) { alert('Heading: ' + heading.magneticHeading); }; function onError(error) { alert('CompassError: ' + error.code); }; //////////////////////////////////////////////////////////////////////////// function watchH() { var options = { frequency: 3000 }; // Update every 3 seconds watchID = navigator.compass.watchHeading(onSuccess, onError, options); } /////////////////////////////////////////////////////////////////////// function clearW() { navigator.compass.clearWatch(watchID); }復制
相關推薦
- Cordova 什么是Cordova? Cordova是用于使用HTML,CSS和JS構建移動應用的平臺。我們可以認為Cordova是一個容器,用于將我們的網絡應用程序與本機移動功能連接。默認情況下,Web應用程序不能使用本機移動功能。這就是Cordova進來的地方。它為網絡應用和移動設備之間的連…
- Hibernate Criterion 在查詢方法設計上能夠靈活的依據Criteria的特點來方便地進行查詢條件的組裝.Hibernate設計了CriteriaSpecification作為Criteria的父接口,以下提供了Criteria和DetachedCriteria.Criteria和DetachedCriteria的主要差別在于創建的形式不一樣,Criteria是在線的,所…