1.定义函数
//自定义一个common.js
exports.install=function(Vue){
Vue.prototype.dateToBatch =function(date) {
// date = '2019-11-20 16:32'
var array = date.split(' ');
var date = array[0]
var time = array[1]
date= date.split('-').join('')
time= time.split(':').join('')
return date+time
};
Vue.prototype.bbb=function() {
......
}
}
2.挂载在main.js上
//引入公共函数
import common from './assets/js/common.js'
Vue.use(common)
3.组件中调用
this.dateToBatch (date)
this.bbb()