LoginSignup
3
2

More than 5 years have passed since last update.

ズンドコキヨシ with Vue.js

Posted at

このビックウェーブに、Vue.jsも行っきまーす!

Screen Shot 2016-03-17 at 8.05.30 PM-minishadow.png

'use strict'

class Zundoko

  constructor: ->
    @data =
      kiyoshi: false
      zun: 0
      items: []

  methods:

    push: ->
      doko = Math.random() > 0.5
      str = if doko then 'ドコ' else 'ズン'
      @items.push({text:str})
      if doko and @zun >= 4
        @items.push({text:'キ・ヨ・シ!'})
        @kiyoshi = true
      if !doko then @zun++ else @zun = 0
      return

kiyoshi = new Zundoko()
new Vue({el: '#kiyoshi', data: kiyoshi.data, methods: kiyoshi.methods})

すいません、今ちょうどcoffeeしかなくて。

Jade
#kiyoshi
  button(type="button" @click="push" v-show="!kiyoshi") Push
  ul
    li(v-for="item in items" v-text="item.text")

実物はこちら

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2