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?

computedの使い方 Vue.js

0
Posted at

computed() は関数を受け取り、その関数が return した値を「計算結果」として持つ。そして、その関数の中で使われているリアクティブな値を追跡して、値が変化すると自動的に再計算する。

const totalAmount = computed(() => {
  return 返却する値
})
const totalAmount = computed(() => {
  return expenses.value.reduce((total, expense) => {
    return total + Number(expense.amount)
  }, 0)
})
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?