我需要在基于cordova的 Windows 8手机应用程序中创建并安装自定义的cordova插件.目前,应用程序中的按钮单击处理程序无法查看调用cordova.exec的js对象 该对象,使用调用cordova.exe的函数称为d
          该对象,使用调用cordova.exe的函数称为dlScanner
它有一个函数scanBarcode,它调用cordova.exec
点击处理程序是这样的:
$(document).ready(function () {
        $('#cmdOne').click(function () {
            dlScanner.scanBarcode(
                function (results) {
                    alert(results);
            }), function (err) {
                    alert(err);
            }, 'lowercaseworld'
        });
    }); 
 错误消息是这样的:
TypeError: Cannot read property 'scanBarcode' of undefined
上下文:我使用了Microsoft插件生成器PluginGenerator,找到了here.然后我在应用程序的config.xml文件中使用View Designer,在Visual Studio Community 2015中,将该插件安装到VS拥有的通用cordova Windows 8手机应用程序中早些时候为我创造的.
该插件安装过程将其放在app的config.xml文件中
<vs:plugin name="com.contoso.dlScanner" version="0.1.0" src="C:\Users\TestAndDemo\dlScanner" />
在dlScanner目录(如上所述)中,有src和www目录以及plugin.xml文件
在那个plugin.xml文件是这样的:
<js-module src="www/dlScanner.js" name="dlScanner">
        <clobbers target="dlScanner" />
    </js-module>
    <!-- wp8 -->
    <platform name="wp8">
        <config-file target="config.xml" parent="/*">
            <feature name="dlScanner">
                <param name="wp-package" value="dlScanner"/>
            </feature>
        </config-file>
        <source-file src="src/wp/dlScanner.cs" /> 
 www / dlScanner.js文件包含以下内容:
var dlScanner = {
            scanBarcode: function (successCallback, errorCallback, strInput) {
                cordova.exec(successCallback, errorCallback, "dlScanner", "scanBarcode", [strInput]);
            }
        }
module.exports = dlScanner; 
 我该怎么做才能使点击处理程序看到dlScanner对象?
谢谢
在Cordova初始化并发出deviceready事件后尝试调用该插件.在此处查看有关此活动的更多信息: http://docs.phonegap.com/en/3.5.0/cordova_events_events.md.html#deviceready.