Vue项目常用配置

宋乐
宋乐 5月4日

全局 filter

custom.js

// 2018-11-02 15:12:43  --> 15:12
let subTimeToHour = time => {
    return time.substring(11, 16)
}
export { subTimeToHour }

main.js

import * as customFilters from './filters/custom'
//引入全局filter
Object.keys(customFilters).forEach(key => {
    Vue.filter(key, customFilters[key])
})
  • 需要 webpack 重新编译

引入 Swiper

import '../node_modules/swiper/dist/css/swiper.min.css'
import oswiper from '../node_modules/swiper/dist/js/swiper.min.js'
window.Swiper = oswiper