LoginSignup
3
1

More than 5 years have passed since last update.

Vue.js で data や computed の値の一覧を埋め込んでデバッグを楽にする方法

Last updated at Posted at 2018-07-11

実機テスト中で Vue-Devtools が使えない環境だったり、他の人が作ったVueコンポーネントの構造がどうなっているのか、わけがわからないという状況だったり、たんに開発環境ではHTML自体に埋めておいてすぐに確認したいという場合は、次のタグをさくっとコピペするとデバッグがとても楽になります。

slim または pug 形式になっています。

template(v-if="true")
  table(border=1)
    caption
      | Props
    tr(v-for="(value, key) in $props")
      th(v-text="key")
      td(v-text="value")

  table(border=1)
    caption
      | Variables
    tr(v-for="(value, key) in $data")
      th(v-text="key")
      td(v-text="value")

  table(border=1)
    caption
      | Computed
    tr(v-for="(e, key) in _computedWatchers")
      th(v-text="key")
      td(v-text="e.value")

表示はこんな感じですがもっともっとカオスな状況で効果があります。

See the Pen Vue.js variables simple display by Akira Ikeda (@akicho8) on CodePen.

3
1
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
1