【发布时间】:2018-09-05 19:51:06
【问题描述】:
我已经安装了 cordova 5.3.3,我创建了适用于 android 的应用程序:
cordova create Project
cd Project
cordova platform add android
在那之后,我压缩我的文件:
cd ..
zip -r Project.zip Project
并将其上传到 phonegap build at:
https://build.phonegap.com/apps
在那里创建apk并将其安装在我的android上后,应用程序似乎工作正常,除非我尝试使用插件。
插件功能总是失败,而其余的 javascript 代码工作正常。
我添加的插件如下:
cordova plugin add org.apache.cordova.vibration
cordova platform rm android
cordova platform add android
如果我列出我的插件:
cordova plugin ls
我明白了:
cordova-plugin-whitelist 1.0.0 "Whitelist"
org.apache.cordova.vibration 0.3.13 "Vibration"
使用 phonegap(版本 5.3.6)或仅上传仅包含“www”文件夹和“config.xml”文件的 zip 文件时,我会遇到相同的行为。
我还在 stackoverflow 中阅读了这些类似的问题:
phonegap plugins 5.1.1 cli don't work
但在我的情况下,它们似乎对我没有帮助。
index.html 代码:
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="msapplication-tap-highlight" content="no" />
<!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<title>Hello World</title>
</head>
<body>
<div class="app">
<h1>Teste Vibra</h1>
<button type="button" id="vibrar">Vibrar</button>
</div>
<script type="text/javascript" src="cordova.js"></script>
<script src="js/jquery-2.1.4.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript">
</script>
</body>
javascript代码:
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
$(function(){
$( "#vibrar" ).click(function() {
navigator.vibrate(3000);
alert("abc");
});
})
}
我正在使用 JQuery 库 2.1.4。
【问题讨论】:
标签: cordova phonegap-plugins phonegap-build cordova-plugins