VS 11 Ultimate Metro 应用程序中的 WinJS.UI.getControl

发布于 2025-01-02 06:10:09 字数 108 浏览 4 评论 0原文

WinJS.UI.getControl 未在 VS 11 Ultimate 中定义。有没有其他方法可以做同样的事情?

我的意思是,如何在 javascript 中访问 winJS 控件?

WinJS.UI.getControl is not defined in VS 11 Ultimate. Is there any alternatives there to do the same?

I mean, how can i access winJS controls in javascript?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

゛清羽墨安 2025-01-09 06:10:09

不知道这个问题是否仍然有效以及最初的原因是什么,但无论如何:最好记住,从 Consumer Preview 附带的 WinJS 版本开始,不再有 WinJS.UI.getControl() 函数,而是应使用语法

var appBar = document.getElementById("appBar").winControl;

有关详细信息,请参阅官方迁移指南

Don't know whether this issue is still valid or not and what the original cause was, but anyway: it's good to remember that starting from the WinJS version shipped with Consumer Preview there is no WinJS.UI.getControl() function anymore, instead one should use syntax

var appBar = document.getElementById("appBar").winControl;

See the official migration guide for details.

夢归不見 2025-01-09 06:10:09

IDE 中的源代码没有任何区别。这意味着没有在 Ultimate 中定义但在 Express 中定义的东西。 VS Ultimate 为您提供了更多工具,但不会更改您拥有的代码(除非使用此类工具:))。

确保你已经包含了 ui.js

<script type="text/javascript" src="winjs/js/ui.js"></script>

你可以像这样使用它:

var appBar = WinJS.UI.getControl(document.getElementById("appBar"));

There is no difference in the IDE in terms of your source code. Meaning there is no such thing as it is defined in Ultimate but not Express. VS Ultimate gives you more tools, but does not change the code you have (unless by using such tools :) ).

Make sure you have included ui.js

<script type="text/javascript" src="winjs/js/ui.js"></script>

You can use it like this:

var appBar = WinJS.UI.getControl(document.getElementById("appBar"));
她比我温柔 2025-01-09 06:10:09

看起来终极版中包含的 JavaScript 项目模板有一个错误,默认情况下不包含 winjs 文件夹和该文件夹中的 JavaScript 文件。

只需从 Express 版本复制该文件夹或将其添加到项目模板中即可。

Looks like there is a bug with JavaScript project template included with the ultimate edition, the winjs folder and the JavaScript files in the folder are not included by default.

Just copy that folder from the express edition or add it to the project template.

土豪我们做朋友吧 2025-01-09 06:10:09

@空指针
我注意到你有 另一个关于 Metro 应用程序中缺少 JS 引用的问题。就我个人而言,我已经在许多 Windows 8 计算机上安装了 VS Ultimate,没有出现任何问题。

我想知道您的安装人员是否遇到问题。您可以尝试卸载/重新安装 Visual Studio 并查看是否可以修复问题。

您还可以检查“C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\ProjectTemplates\JavaScript\Windows Metro style\1033”中的zip文件的内容,并检查它们是否包含9个标准JS文件在他们之中。如果它们丢失,那么您的安装程序可能在某个时候遇到了问题。

@Null Pointer
I notice that you've got another question about missing JS references in Metro apps. Personally, I've installed VS ultimate on a number of Windows 8 machines without a problem.

I'm wondering if you're installer had problems. Could you try doing an uninstall/reinstall of Visual Studio and seeing if that fixes things.

Also can you check the contents of the zip files in "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\ProjectTemplates\JavaScript\Windows Metro style\1033" and check that they contain the 9 standard JS files in them. If they are missing then your installer likely encountered a problem at some point.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文