LoginSignup
1
2

More than 5 years have passed since last update.

requirejs で module 作る時の雛形 (jQuery利用版)

Last updated at Posted at 2016-04-21

es5 で書くときの雛形。

es2015は、まだIEへの対応が弱いらしいので、
es5で書かなくてはならないときに使う。

使い方

'MyClassName' の箇所を任意のクラス名に置き換えて使う。
jQueryのパス適宜修正が必要 ※lib/jquery-1.8.2.min の部分。
(不要なら消す)

(function (global, factory) {
  if (typeof define === 'function' && define.amd) {
    // AMD. Register as an anonymous module.
    define(['lib/jquery-1.8.2.min'], factory);
  } else if (typeof module === 'object' && module.exports) {
    // CommonJS
  } else {
    // Browser globals
    global.MyClassName = factory(jQuery);
  }
}((this.self || global), function ($) {
  'use strict';

  var MyClassName = function(){
  };

  MyClassName.prototype = {
    constructor: MyClassName,
    test: function(){
      alert('test');
    }
  }

  return MyClassName;
}));
1
2
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
2