EN
이 콘텐츠는 한국어로 제공되지 않아 영어 버전으로 표시됩니다.

WinJS.Class.define function

Applies to Windows and Windows Phone

Defines a class using the given constructor and the specified instance members.

Syntax


var object = WinJS.Class.define(constructor, instanceMembers, staticMembers);

Parameters

constructor

Type: Function

A constructor function that is used to instantiate this type.

instanceMembers

Type: Object

The set of instance fields, properties, and methods made available on the type.

staticMembers

The set of static fields, properties, and methods made available on the type.

Return value

Type: Object

The newly-defined type.

Remarks

For more information about using this method, see Defining and deriving types with WinJS.Class. For information about using constructors to define types in JavaScript, see Using Constructors to Define Types.

Examples

The following code shows how to use this method.


var Robot = WinJS.Class.define(
    function (name) {
        this.name = name;
    },
    { 
        modelName: "", 
        on: function () {
            // Turn the robot on.
        },
        off: function () {
            // Turn the robot off.
        }
    },
    {
        harmsHumans: false,
        getModels: function () {
            // Return all the available models.
        }
    });

var myRobot = new Robot("Mickey");

myRobot.modelName = "4500";
myRobot.on();

Robot.harmsHumans = false;
var models = Robot.getModels();

Requirements

Minimum supported client

Windows 8 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Minimum supported phone

Windows Phone 8.1

Namespace

WinJS.Class

Library

Base.js

 

 

표시:
© 2014 Microsoft