petite-vue sample 6

<script type="module">
import { createApp } from 'https://unpkg.com/petite-vue?module'

function Counter(props) {
  return {
    $template: '#counter-template',
    count: props.initialCount,
    inc() {
      this.count++
    }
  }
}

createApp({
  Counter
}).mount()
</script>

<template id="counter-template">
  My count is {{ count }}
  <button @click="inc">+1</button>
</template>

<div v-scope="Counter({ initialCount: 1 })"></div>
<div v-scope="Counter({ initialCount: 2 })"></div>

元記事を表示する