Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <div id="app">
  <input v-model="dateInput" type="date" min="1868-10-23" max="2118-04-30">
  <h2>{{ }}{{wareki.year}}年</h2>




                var vm = new Vue({
  el: '#app',
  data: {
    dateInput: '2019-05-01', // 初期値
  computed: {
    wareki: function () {
      var _dateInput = new Date(this.dateInput), // 入力値
          _eras = [
                  "name": "令和",
                  "kana": "れいわ",
                  "initial": "R",
                  "begin": "2019-05-01",
                  "end": "9999-12-31",
                  "name": "平成",
                  "kana": "へいせい",
                  "initial": "H",
                  "begin": "1989-01-08",
                  "end": "2019-04-30",
                  "name": "昭和",
                  "kana": "しょうわ",
                  "initial": "S",
                  "begin": "1926-12-25",
                  "end": "1989-01-07",
                  "name": "大正",
                  "kana": "たいしょう",
                  "initial": "T",
                  "begin": "1912-07-30",
                  "end": "1926-12-24",
                  "name": "明治",
                  "kana": "めいじ",
                  "initial": "M",
                  "begin": "1868-10-23",
                  "end": "1912-07-29",
      // filterで絞り込み
      return _eras.filter( function(item) {
        var _dateBegin = new Date(item.begin + " 00:00:00 +0900"),
            _dateEnd = new Date(item.end + " 23:59:59 +0900"),
            _year = 0;
        // Date.getTimeを使って開始後かつ終了前を判定
        if ( _dateInput.getTime() >= _dateBegin.getTime()
             && _dateInput.getTime() <= _dateEnd.getTime() ) {
          // 年数を計算
          _year = _dateInput.getFullYear() - _dateBegin.getFullYear() + 1;
          // 1年なら元年にしてプロパティに追加
          item.year = (_year === 1) ? "元": _year;
          return item;