current position:Home>Summary of filter scheme used in JS code in Vue

Summary of filter scheme used in JS code in Vue

2022-05-15 02:07:01Wooden house x

vue Inside JS The code uses filter Summary of the plan

1. Demand background
  • Recently vue Used in the project filter, A common situation is in vue Used in template , There are also some situations in JS The code uses , Here's a summary :
  • // 1. Add one globally filter(Vue Introduced separately ), Such as :
    Vue.filter('dictionary', function(value, code) {
        if (code) {
           return localStorage.get('DICT_DATA')[code];
        return ''
    // 2. Use... In templates :
    // 3. stay JS Use in , Method 1:
    // 4. stay JS Use in , Method 2:

copyright notice
author[Wooden house x],Please bring the original link to reprint, thank you.

Random recommended