1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Classの登録はどうするの? - Metro App (Javascript)

Last updated at Posted at 2012-12-26

WinJS.Class.define() を使って、いざクラスを登録してみたが、
どこからも参照できない…!
という悲しい状況に陥ってしまった方、いらっしゃいませんか??

はいー( ´ ∇ ` )ノ

…冷静に考えると、わかりますね。
Namwspace に登録する必要があります。

そんなとき、Class.define の使い方が、とてもずばりわかりやすいサンプルが、
なんと Namespace のページにありました!

ここ ↓
Organizing your code with WinJS.Namespace (Metro style apps using JavaScript and HTML)

以下、該当部分の引用です。

WinJS.Namespace.define("Robotics", {
    Robot: WinJS.Class.define( function(name) {
            this.name = name;
        }, 
        { modelName: "" }, 
        { harmsHumans: false, obeysOrders: true })
});
var myRobot = new Robotics.Robot("Mickey");
myRobot.modelName = "4500";
var harm = Robotics.Robot.harmsHumans; 

リファレンスは少しずつでも隅々まで根気よく読み込んでいくと、
たくさんのヒントが埋まっていて、わくわくしますね!

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?