cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <div id="app">
  <div>
		<simple-counter></simple-counter>
  	<simple-counter></simple-counter>
  	<simple-counter></simple-counter>
	</div>
	<div>
		<simple-counter2></simple-counter2>
  	<simple-counter2></simple-counter2>
  	<simple-counter2></simple-counter2>
	</div>
</div>



            
          
!
            
              var data = { counter: 0 };

Vue.component('simple-counter', {
  template: '<button v-on:click="counter += 1">{{ counter }}</button>',
  // data is technically a function, so Vue won't
  // complain, but we return the same object
  // reference for each component instance
	
	//単純に冒頭で宣言したdataを参照するため、
	//それぞれのカウンターが同じ値を参照していることになる。
  data: function () {
    return data;
  }
});

Vue.component('simple-counter2', {
	//カウンターを+1して、は普通にJSのコードとして読み取られて実行される。
	//ここでの counter はコンポーネント用のそれぞれのインスタンスが独自に持つ値
  template: '<button v-on:click="counter += 1">{{ counter }}</button>',
  // data is technically a function, so Vue won't
  // complain, but we return the same object
  // reference for each component instance
  data: function () {
    return {
			counter: 0
		}
  }
});

new Vue({
  el: "#app",
});
            
          
!
999px
Loading ..................

Console