0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ディレクティブ集

0
Last updated at Posted at 2020-09-03

v-once

これだとhello worldが書き換わってしまう

<div id="app">
  <p>{{message}}</p>
  <p>{{sayHi()}}</p>
</div>

new Vue({
	el:'#app',
  data:{
  	message:'Hello world'
  },
  methods:{
  	sayHi(){
    this.message='Hello vuejs'
    return 'Hi'
    }
  }
})

そんなとき、一度だけの変化で留めておきたいときは

<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>

<div id="app">
  <p v-once>{{message}}</p>
  <p>{{sayHi()}}</p>
</div>

new Vue({
	el:'#app',
  data:{
  	message:'Hello world'
  },
  methods:{
  	sayHi(){
    this.message='Hello vuejs'
    return 'Hi'
    }
  }
})

v-html

v-bind: 省略して:だけでもok

v-on

イベント一覧
https://developer.mozilla.org/ja/docs/Web/Events

キー修飾

v-on:keyup.enter

v-onの短縮

v-model

<div id="app">
  <input type="text" v-model="message">
  <h1>{{message}}</h1>
</div>

new Vue({
	el:"#app",
  data:{
  	message:'こんにちは'
  }
})
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?