vue global filter introduction method

1. Introduction method of vue global filter

1. Write js filtering code externally

The code is as follows (example):

//全局过滤器

const filter = (Vue) => {
    
    
	Vue.filter('方法名', (n) => {
    
    
		//操作
	});
}

export default filter

2. mian.js imports js code

The code is as follows (example):

//过滤器
import filter from './XXX.js 文件路径地址';
//调用准备好的js文件
filter(Vue);

Guess you like

Origin blog.csdn.net/weixin_46746389/article/details/118186725