var randomNum = Math.floor(Math.random() * customVal); //customVal 可以是自訂的參數,譬如以視窗或指定div的高或寬
2018年7月20日 星期五
jquery 算出隨機整數字
2018年7月10日 星期二
jquery引用網址
jquery官方提供的網址
google提供的網址
<script src='//code.jquery.com/jquery-2.1.4.min.js'></script>
google提供的網址
<script src='//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js'></script>
注意:
Google CDN網址雖然是比較好的選擇,但為了避免被大陸地區google的服務會有異常,建議使用jquery官方提供的引用網址
後方的數字可更改以符合最新版次,jquery版本資訊可見這裡
2018年7月7日 星期六
Android studio使用emulate Android模擬器時出現device still connecting bug臭蟲的修正方式
狀況:
在終端機使用$ cordova emulate android指令時,無法正常開啟並執行Android studio的模擬器
錯誤碼:
在終端機使用$ cordova emulate android指令時,無法正常開啟並執行Android studio的模擬器
錯誤碼:
(node:1225) UnhandledPromiseRejectionWarning: CordovaError: Failed to execute shell command "getprop,dev.bootcomplete"" on device: Error: adb: Command failed with exit code 1 Error output:
error: device still connecting
修正方式:
Step1.
開啟電腦資料夾至APP專案內下面這個位置的emulator.js檔案
yourAppName/platforms/android/cordova/lib/emulator.js
Step2.
以編碼軟體開啟emulator.js檔案,並且找到下面語法
if ((error && error.message &&
(error.message.indexOf('not found') > -1)) ||
(error.message.indexOf('device offline') > -1))
Step3.
把上面這段語法改為如下:(紅色字標註是新增的部分)
if ((error && error.message &&
(error.message.indexOf('not found') > -1)) ||
(error.message.indexOf('device offline') > -1) ||
(error.message.indexOf('device still connecting') > -1))
Step4.
修改完並且儲存後,再次於終端機執行模擬指令
$ cordova emulate android
即可順利開啟模擬器
Reference:
- https://stackoverflow.com/questions/50935337/failed-to-execute-shell-command-getprop-dev-bootcomplete-on-device-error-for
- https://issues.apache.org/jira/browse/CB-14165
- https://github.com/apache/cordova-android/pull/457/files
訂閱:
文章 (Atom)