Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

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

Packages

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.

Behavior

Save Automatically?

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.

HTML

              
                <div id="main-content">
  <a href="#" class="btn btn-default" v-on:click="insertPeriod"> 追加</a>
  <table class="table table-hover">
    <tbody>
      <tr>
        <th style="width:10%">No</th>
        <th>開始</th>
        <th>終了</th>
        <th style="width:10%"></th>
      </tr>
      <tr v-for="(item, index) in items"
          :key="item.no">
        <th>{{index+1}}</th>
        <th>
          <input type="text"
                 class="form-control input-sm datepicker"
                 name="startDate[]"
                 v-bind:data-index="'startDate-'+index"
                 v-on:change="setValue('startDate', index, $event.target.value)"
                 v-on:keyup="setValue('startDate', index, $event.target.value)">
        </th>
        <th>
          <input type="text"
                 class="form-control input-sm datepicker"
                 name="endDate[]"
                 v-bind:data-index="'endDate-'+index"
                 v-on:change="setValue('endDate', index, $event.target.value)"
                 v-on:keyup="setValue('endDate', index, $event.target.value)">
        </th>
        <th>
          <span class="badge bg-red del" v-on:click="delPeriod(item, index)">削除する</span>
        </th>
      </tr>
    </tbody>
  </table>
</div>
              
            
!

CSS

              
                
              
            
!

JS

              
                var datepickerDefult;
$(function(){
  datepickerDefult = {
            showButtonPanel: true,
            constrainInput: true, // dateFomartで指定された形式でしか、入力値を受け付けないようになります。
            showMonthAfterYear: true,//ヘッダー内で年の後ろに月を表示するか否かを指定します。
            showOtherMonths: true,
            selectOtherMonths:true,
            changeMonth: true,
            changeYear: true,
            altFormat: 'yy-mm-dd',
            dateFormat: 'yy-mm-dd', // 解析と表示をする日付のフォーマットを指定します
            yearSuffix: "年",
            dayNames: ["日曜日", "月曜日", "火曜日", "水曜日", "木曜日", "金曜日", "土曜日"], //
            dayNamesMin: ["日", "月", "火", "水", "木", "金", "土"],
            monthNames: [ "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"],
            monthNamesShort: [ "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"],
            firstDay: 0,
            closeText: "閉じる",
            showAnim: "fadeIn",
            onSelect: function(dateText, inst) {
                var target = $(this).data('index');
                var split = target.split("-");

                app.setPeriodValue(split[0], split[1], dateText);
            }
        };
        $( ".datepicker" ).datepicker(datepickerDefult);
});
var app = new Vue({
        el: '#main-content',
        data: {
            items: [],
            newdNo: 1
        },
        methods:{
            insertPeriod: function(){
                var self = this;

                if(self.items.concat().length > 0)
                    self.newdNo = Math.max.apply(null, self.items.concat().map(function(item){return item.no;})) + 1;

                this.items.push({
                    startDate: '',
                    endDate: '',
                    no: self.newdNo
                });
                
                setTimeout(function(){
                    $( ".datepicker" ).datepicker (datepickerDefult);
                }, 0);
            },
            delPeriod: function (item, index) {
                var self = this;
                self.items.splice(index, 1);
            },
            setPeriodValue: function(key, index, value){
                var self = this;
                self.$set(self.items[index], key, value);
            }
        }
    });
              
            
!
999px

Console