Facebook
From Beefy Mousedeer, 4 Years ago, written in HTML5.
Embed
Download Paste or View Raw
Hits: 138
  1. <!DOCTYPE html>
  2.   <head>
  3.     <meta charset="utf-8">
  4.     <meta name="viewport" content="width=device-width, initial-scale=1">
  5.     <link rel="stylesheet" href="https://unpkg.com/buefy/dist/buefy.min.css">
  6.   </head>
  7.  
  8.   <body>
  9.     <div id="app">
  10.       <section>
  11.         <b-field>
  12.           <b-input type="number" v-model="total" min="0" max="255"></b-input>
  13.         </b-field>
  14.         <b-field grouped group-multiline>
  15.           <b-checkbox-button
  16.               v-model="checked"
  17.               :native-value="item"
  18.               v-for="(item,key) in items" :key="key">{{ item }}</b-checkbox-button>
  19.         </b-field>
  20.       </section>
  21.     </div>
  22.  
  23.     <script src="https://unpkg.com/vue"></script>
  24.     <!-- Full bundle -->
  25.     <script src="https://unpkg.com/buefy/dist/buefy.min.js"></script>
  26.  
  27.     <!-- Individual components -->
  28.     <script src="https://unpkg.com/buefy/dist/components/table"></script>
  29.     <script src="https://unpkg.com/buefy/dist/components/input"></script>
  30.  
  31.     <script>
  32.      new Vue({
  33.          el: '#app',
  34.          data() {
  35.              return {
  36.                  total: "42",
  37.                  items: null,
  38.                  checked: [],
  39.              }
  40.          },
  41.          watch: {
  42.              total(val, oldVal) {
  43.                  console.log(`total: ${oldVal} -> ${val}`)
  44.                  this.update()
  45.              },
  46.              items(val, oldVal) {
  47.                  console.log(`items: ${oldVal} -> ${val}`)
  48.              },
  49.              checked(val, oldVal) {
  50.                  console.log(`checked: ${oldVal} -> ${val}`)
  51.              }
  52.          },
  53.          methods: {
  54.              update() {
  55.                  this.items = new Array(parseInt(this.total))
  56.                  for(let i=0; i<this.items.length; i++) {
  57.                      this.items[i] = `${i+1}`
  58.                  }
  59.              }
  60.          },
  61.          mounted() {
  62.              this.update(this.total)
  63.          }
  64.     })
  65.    </script>
  66.   </body>
  67. </html>
  68.