LoginSignup
6
1

More than 3 years have passed since last update.

[Vue.js] 複数の引数を持つfilterを使ってみたメモ

Last updated at Posted at 2019-05-29

Filter.js

src直下にpluginsディレクトリを切り、その中にfilter処理だけを書くFilter.jsを置く


export default {
  install(vue) {
  // 複数の引数を持つfilterはこれ↓
    vue.filter('関数名', (value, sum) => {
        console.log('関数名',value,sum)
      return (value / sum) * 100
    })
  },
}

使い方


<p>
{{ 【value】 | percentageCalculation(【sum】) | decimalPointShaping }}%
</p>

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