我尝试使用自定义插件调用C#类。我使用Cordova创建了一个通用的Windows 10应用程序。这是我的C#类,名为Echo.cs
using System;
using WPCordovaClassLib.Cordova;
using WPCordovaClassLib.Cordova.Commands;
using WPCordovaClassLib.Cordova.JSON;
public class Echo : BaseCommand
{
public void echo(string options)
{
// all JS callable plugin methods MUST have this signature!
// public, returning void, 1 argument that is a string
DispatchCommandResult();
}
}
当设备准备就绪时,我致电
function onDeviceReady() {
// Handle the Cordova pause and resume events
document.addEventListener( 'pause', onPause.bind( this ), false );
document.addEventListener( 'resume', onResume.bind( this ), false );
// TODO: Cordova has been loaded. Perform any initialization that requires Cordova here.
var win = function (result) {
console.log("Success");
console.log(result);
};
var fail = function (result) {
console.log("Fail");
console.log(result);
};
cordova.exec(win, fail, "Echo", "echo", ["input string"]);
};
但总是因此错误而失败;缺少命令错误。它似乎无法找到班级?
https://cordova.apache.org/docs/en/latest/guide/platforms/wp8/plugin.html
没有帮助。我可能错过了什么?我已尝试将.cs文件放在不同的项目(属于同一解决方案),插件文件夹,根文件夹等中。