LoginSignup
6
6

More than 5 years have passed since last update.

Vue.jsでBootstrapのProgress Barを制御するサンプル

Last updated at Posted at 2015-12-15

vue.jsの勉強を兼ねて、BootstrapのProgress Barを制御するサンプルを作ってみました。

<div class="container" id="simple">

  <div class="progress progress-striped active">
    <div class="progress-bar" :style=" progressWidth">
    <span>{{ progress }}%</span>
    </div>
  </div>
  <button class="btn btn-default" v-on:click="start" type="submit">Button</button>
</div>
var app = new Vue({
  el: '#simple',
  data: {
    progress: 15,
  },
  computed: {
        progressWidth: function(){
             return "width:" + this.progress + "%";
        }
  },
  created: function(){
  },
  methods: {
    start: function() {
      this.progress = 75
    }

  }
})

ボタンをクリックするとProgress Barのゲージが15%から75%に増加します。
jsfddileでのサンプルはこちら。 http://jsfiddle.net/Hiroshi_Obata/dgxavvgj/embedded/result/

vue.jsを始めるにあたり、いくつかのサイトを参考にしたのですが、v-attrを使っていたり、v-onのイベントの書き方が違っていたりとちょっと苦労しました。v 1.0.0が出た2015/10/26以前の記事は参考にしない方がよさそう。

6
6
1

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
6
6