1.新建utils/config.js,vue的插件和配置都能写在里面
1.utils/config.js
Vue.filter("format",function(val){if(val.length>6){val=val.slice(0,6)+"..."}return val})
2.使用
<template><div>music<p>{{"hello world" | format()}}</p> //<p>{{data.name |format()}}</p></div></template>

