Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.16/vue.js"></script>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  
  <button @click="addSection" class="section-btn">Add Section</button>
  
  <vsection v-for="section in sections">
    {{ section.content }}
  </vsection>
  
  <template id="section-template">
    <div class="section">
      <slot></slot>
    </div>
  </template>
</body>
</html>
 
.section {
  border: 1px solid red;
}
 
Vue.component('vsection', {
    template: '#section-template'
});
new Vue({
  el: 'body',
  
  data: {
    sections: [
            { content: 'add a section' }
        ]
  },
  
  methods: {
    addSection: function () {
            this.sections.push({
              content: 'another section'
            });
        }
  }
});
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers