在JavaScript代碼中使用cordova.exec()API。
// added the cordova plugin definition in wlCommonInit(), as recommended by other answers I read (can't remember where),
// because the cordova event `deviceready` is fired and handled internally by MobileFirst
function wlCommonInit() {
// copied module id from https://github.com/driftyco/ionic-plugin-keyboard/blob/master/plugin.xml
cordova.define("com.ionic.keyboard.keyboard", function(require, exports, module) {
// copied code from https://github.com/driftyco/ionic-plugin-keyboard/blob/master/www/keyboard.js
var argscheck = require('cordova/argscheck'),
utils = require('cordova/utils'),
exec = require('cordova/exec');
var Keyboard = function() {
};
Keyboard.hideKeyboardAccessoryBar = function(hide) {
exec(null, null, "Keyboard", "hideKeyboardAccessoryBar", [hide]);
};
Keyboard.close = function() {
exec(null, null, "Keyboard", "close", []);
};
Keyboard.show = function() {
exec(null, null, "Keyboard", "show", []);
};
Keyboard.disableScroll = function(disable) {
exec(null, null, "Keyboard", "disableScroll", [disable]);
};
/*
Keyboard.styleDark = function(dark) {
exec(null, null, "Keyboard", "styleDark", [dark]);
};
*/
Keyboard.isVisible = false;
module.exports = Keyboard;
});
// Manually-register custom plugin
if (window.cordova && !window.cordova.plugins) {
window.cordova.plugins = {};
}
// Do this instead of `clobbers` definition in native/www/default/worklight/cordova_plugins.js
window.cordova.plugins.Keyboard = cordova.require('com.ionic.keyboard.keyboard');
}
請提供您做了什麼?分享代碼。您使用的是什麼MFP版本「6.3」或「7」? –
對不起。 –