“'WinJS'没有定义。”和“Windows”没有定义。“

时间:2013-07-24 12:14:30

标签: windows winjs

抱歉我的英文。 我开始学习开发Windows应用商店应用。我找到了一个教程here。我按照它,创建一个新的Javascript Windows应用商店应用程序。但是当我构建我的应用程序时,没有添加任何代码,JSHint会显示我的错误:

'WinJS' is not defined.
'Windows' is not defined

有我的default.html

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>SimpleChanel9Reader</title>

    <!-- WinJS references -->
    <link href="//Microsoft.WinJS.1.0/css/ui-dark.css" rel="stylesheet" />
    <script src="//Microsoft.WinJS.1.0/js/base.js"></script>
    <script src="//Microsoft.WinJS.1.0/js/ui.js"></script>

    <!-- SimpleChanel9Reader references -->
    <link href="/css/default.css" rel="stylesheet" />
    <script src="/js/default.js"></script>
</head>
<body>
    <div id="main">
        <header id="banner">
            <button id="backbutton" class="win-backbutton"></button>
            <h1 id="maintitle" class="win-title">Welcome to Chanel9</h1>
        </header>
        <section id="content"></section>
    </div>
</body>
</html>

并且default.js

// For an introduction to the Blank template, see the following documentation:
// http://go.microsoft.com/fwlink/?LinkId=232509
(function () {
    "use strict";
    WinJS.Binding.optimizeBindingReferences = true;

    var app = WinJS.Application;
    var activation = Windows.ApplicationModel.Activation;

    app.onactivated = function (args) {
        if (args.detail.kind === activation.ActivationKind.launch) {
            if (args.detail.previousExecutionState !== activation.ApplicationExecutionState.terminated) {
                // TODO: This application has been newly launched. Initialize
                // your application here.
            } else {
                // TODO: This application has been reactivated from suspension.
                // Restore application state here.
            }
            args.setPromise(WinJS.UI.processAll());
        }
    };

    app.oncheckpoint = function (args) {
        // TODO: This application is about to be suspended. Save any state
        // that needs to persist across suspensions here. You might use the
        // WinJS.Application.sessionState object, which is automatically
        // saved and restored across suspension. If you need to complete an
        // asynchronous operation before your application is suspended, call
        // args.setPromise().
    };

    app.start();
})();

有关于我的Visual Studio的一些信息

Microsoft Visual Studio Ultimate 2012
Version 11.0.50727.1 RTMREL
Microsoft .NET Framework
Version 4.5.50709

Installed Version: Ultimate

Architecture and Modeling Tools   04940-004-0039002-02068
Microsoft Architecture and Modeling Tools

UML® and Unified Modeling Language™ are trademarks or registered trademarks of the Object Management Group, Inc. in the United States and other countries.

LightSwitch for Visual Studio 2012   04940-004-0039002-02068
Microsoft LightSwitch for Visual Studio 2012

Office Developer Tools   04940-004-0039002-02068
Microsoft Office Developer Tools

Team Explorer for Visual Studio 2012   04940-004-0039002-02068
Microsoft Team Explorer for Visual Studio 2012

Visual Basic 2012   04940-004-0039002-02068
Microsoft Visual Basic 2012

Visual C# 2012   04940-004-0039002-02068
Microsoft Visual C# 2012

Visual C++ 2012   04940-004-0039002-02068
Microsoft Visual C++ 2012

Visual F# 2012   04940-004-0039002-02068
Microsoft Visual F# 2012

Visual Studio 2012 Code Analysis Spell Checker   04940-004-0039002-02068
Microsoft® Visual Studio® 2012 Code Analysis Spell Checker

Portions of International CorrectSpell™ spelling correction system © 1993 by Lernout & Hauspie Speech Products N.V. All rights reserved.

The American Heritage® Dictionary of the English Language, Third Edition Copyright © 1992 Houghton Mifflin Company. Electronic version licensed from Lernout & Hauspie Speech Products N.V. All rights reserved.

Visual Studio 2012 SharePoint Developer Tools   04940-004-0039002-02068
Microsoft Visual Studio 2012 SharePoint Developer Tools

BraceCompleter   1.0
Automatically inserts closing braces after typing an open brace and pressing Enter.

CodeMaid   #114
CodeMaid is an open source Visual Studio extension to cleanup, dig through and simplify our C#, C++, F#, VB, XAML, XML, ASP, HTML, CSS and JavaScript coding.

Written by Steve Cadwallader, for more information visit http://www.codemaid.net/

jslint.VS2012   1.0
Adds JSLlint support into Visual Studio

NuGet Package Manager   2.0.30625.9003
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

PreEmptive Analytics Visualizer   1.0
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

SQL Server Data Tools   11.1.20627.00
Microsoft SQL Server Data Tools

Visual Studio 11 Editor Extension   1.0
Information about my package

VSCommands11   11.0
VSCommands 11

Web Developer Tools   1.0.30710.0
Microsoft Web Developer Tools contains the following components:
Page Inspector: Tool that offers an efficient way to decompose Web Applications and diagnose front-end issues.
Web Publishing: Extensions required for Web Publishing for both hosted servers as well as on premises.
Web Form Templates: Includes the default templates for Web Form Applications.
Editor Extensions: Includes HTML, CSS, and JS editor extensions that greatly enhance the development experience.

ZenCoding   0.7
Danny Zen Coding is a visual studio plugin for high-speed HTML, XML, XSL (or any other structured code format) coding and editing.

请帮助我,当我构建每个Javascript Windows应用商店应用程序时出现此错误。

1 个答案:

答案 0 :(得分:0)

尝试通过NuGet添加它:“Install-Package WinJS”

这将确保它安装在解决方案中。