Geo*_*rds 5 android azure typescript nativescript
我正在尝试开发一个 nativescript 插件来使用 Azure SDK 执行一些功能。SDK的文档如下所示:
所以我在我的插件中添加了以下功能:
MobileServiceUser.newUser = function (userId, client) {
var userObject = com.microsoft.windowsazure.mobileservices.authentication.MobileServiceUser(userId); // causing the error
client.setCurrentUser(userObject);
};
Run Code Online (Sandbox Code Playgroud)
UserId 是一个字符串。
但是,最上面一行抛出错误:
JS:错误:试图将无效的“this”链接到 Java 对象
我有一个完整的 repo,显示了在Github上创建这个问题的最小实现。
对于如何解决此问题的任何建议,我将不胜感激。
这个答案有点晚了,但我最近自己也遇到了这个问题。希望这个答案对将来的人有所帮助!
该错误有点简单,但如果您查看代码源,您会发现它实际上告诉您不能将变量链接到对象/类本身作为引用:
MobileServiceUser.newUser = function (userId, client) {
var userObject = com.microsoft.windowsazure.mobileservices.authentication.MobileServiceUser(userId);
};
Run Code Online (Sandbox Code Playgroud)
当你想要实例化一个类时,你需要使用关键字new
来表示这个动作。如果没有new
在类构造函数调用之前列出,程序只会看到您userObject
在类本身之间建立了直接链接。这应该可以解决您的问题:
var userObject = new com.microsoft.windowsazure.mobileservices.authentication.MobileServiceUser(userId);
Run Code Online (Sandbox Code Playgroud)
干杯~Px
归档时间: |
|
查看次数: |
476 次 |
最近记录: |