Vue2.x Cli3.x 自定义过滤器

main.js

//自定义过滤器
Vue.filter("to-uppercase",function(value){
  return value.toUpperCase();
})

Vue.filter("snippet",function(value){
  return value.slice(0,100) + "...";
})

HelloWorld.vue

<template>
  <div class="hello">
    <h1>博客总览</h1>
    <div id="bigbg" v-for="blog in blogs">
      <h3>{{blog.title | to-uppercase}}</h3>
      <p>{{blog.body | snippet}}</p>
    </div>
  </div>
</template>
Last modification:May 31st, 2019 at 09:27 am
If you think my article is useful to you, please feel free to appreciate

Leave a Comment