LoginSignup
0
0

More than 3 years have passed since last update.

[Vue.js]methodsを使う

Posted at

簡単なmethodを使う

js
new Vue({
    data:{
    },
    methods:{
//SayHi!!!と言うメソッドを作る
    SayHi:function(){
        return 'SayHi!!!'
    }
html
//SayHi!!!と表示される
<p>{{sayHi()}}</p>

dataから呼び出したものをメソッドに使う

   data:{
         message:'hello'     
}
    SayHi:function(){
//クォテーションをつけない、thisをつけないとアクセスできない
        return this.message;
    }

これでhelloを呼び出すことができる

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