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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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="app">
<!--  component ;is=で動的にコンポーネントを変えることができる  -->
<keep-alive>
  <component :is="selected">
    <!--  ボタンをクリックしたら、コンポーネントについての値、selectedを変更する
          単にjsとして処理されている。この中は -->
    <button @click="selected ='appBlack'">黒</button>
    <button @click="selected ='appWhite'">白</button>
    
    <!--   メインのコンポーネントにあるlabelの値を使っている   -->
    <h2 class="label" v-bind:class="fontcolor"> {{ label }} </h2>
    フォントカラー
    <button @click="fontcolor ='red'">赤</button>
    <button @click="fontcolor ='green'">緑</button>
    
    <!--   バインドされている方は、コンポーネントが変わっても残る   -->
    <input v-model="label" /> バインドされてる
    <input/> バインドされてない
  </component>
</keep-alive>
  
</div>


<!-- 黒のボトルのテンプレート -->
<script type="text/x-template" id="black">
  <div class="black">
	  <slot></slot>
  </div>
</script>

<!-- 白のボトルのテンプレート -->
<script type="text/x-template" id="white">
  <div class="white">
	  <slot></slot>
  </div>
</script>
              
            
!

CSS

              
                body
  color: blue


.black
  width: 100px
  background-color: black
  
.white
  width: 100px
  background-color: white
  border: solid 1px black
  
.red
  color: red
  
.green
  color: green
              
            
!

JS

              
                const app = new Vue({
  el: '#app',
  data: function() {
    return {
      selected: 'appBlack',
      label: "basic",
      fontcolor: "red"
    };
  },
  components: {
    'appBlack': {
      template: '#black'
    },
    'appWhite': {
      template: '#white'
    }
  }
});
              
            
!
999px

Console