创建了一个基于Ionic2空白模板的Ionic2应用程序。使用Visual Studio 2015更新2.设置Azure移动服务帐户以用作后端。我已经安装了Azure移动应用插件(双击config.xml并选择Azure移动应用,然后单击安装) /config.xml摘录:
<plugin name="cordova-plugin-ms-azure-mobile-apps" version="2.0.0-beta4" />我已经安装了azure-mobile-app.d.ts,如下所示:https://www.nuget.org/packages/azure-mobile-apps.TypeScript.DefinitelyTyped/。VS2015智能感知认为代码有效。
但是,尝试访问chrome控制台中的后端时出现错误:未定义WindowsAzure。
client: WindowsAzure.MobileServiceClient;
...
client = new WindowsAzure.MobileServiceClient('removed url for security');发布于 2016-06-14 14:06:23
代码需要在设备就绪后运行。在Ionic2中,您可以在app.ts中看到一个设备就绪的示例:
constructor(platform: Platform) {
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
StatusBar.styleDefault();
});
}我错误地认为主页构造函数会在设备就绪后触发,但事实并非如此。
发布于 2016-06-23 02:25:09
我能够让WindowsAzure.MobileServiceClient工作的唯一方法是在我的提供程序中声明一个WindowsAzure变量,然后在index.html中手动包含脚本文件MobileServices.Cordova.js作为脚本引用。这不是很理想。有一些打字文件在那里,但它们不再是最新的。
https://stackoverflow.com/questions/37803321
复制相似问题