xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

Vue filter All In One

Vue filter All In One

component filter


<!-- in mustaches -->
{{ message | capitalize }}

<!-- in v-bind -->
<div v-bind:id="rawId | formatId"></div>

filters: {
  capitalize: function (value) {
    if (!value) return ''
    value = value.toString()
    return value.charAt(0).toUpperCase() + value.slice(1)
  }
}

Vue.filter('capitalize', function (value) {
  if (!value) return ''
  value = value.toString()
  return value.charAt(0).toUpperCase() + value.slice(1)
})

new Vue({
  // ...
})

Vue.filter

global filter

import Vue from 'vue';
import Util from '@/utils';
import UtilsCache from '@/utils/cache';

Vue.filter('thousandsFilter', (num, fixed) => {
    return Utils.thousandsFilter(num, fixed);
});

refs

https://vuejs.org/v2/api/#Vue-filter

https://vuejs.org/v2/guide/filters.html





©xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2021-02-21 23:19  xgqfrms  阅读(59)  评论(4编辑  收藏  举报