1
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 3 years have passed since last update.

[Vue.js]関数の引数

Last updated at Posted at 2020-11-16

関数に引数を与える

```html

現在{{num}}回クリックされました

//クリックするたび2足される クリック
```javascript
js
data:{num:0}
methods:{
//これはjsと同じで因数を下の式に当てはめているだけ
      countUp:function(a){
              this.num+=a
                }

関数の引数eventをhtmlに渡す場合

```html //マウスのX軸とY軸を表示

マウスのX軸とY軸を表示するよ

x:{{x}}y:{{y}}

``` ```javascript data:{x:0,y:0}, methods:{ //マウスの場所xとyに対して渡した数を割る mousePosition:function(event,divide){ this.x = event.clientX / divide; this.y = event.clientY / divide; } ```

eventをhtmlに渡す場合 $event として渡す

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