vue项目中获取cdn域名插件

import axios from 'axios'
let CdnPath = {}
CdnPath.install = function (Vue, options) {
Vue.prototype.$_cdnDomain = function () {
if (process.env.NODE_ENV === 'production') {
sessionStorage.setItem('cdnPath', 'https://cdn.hhhhaaaa.com');
} else {
sessionStorage.setItem('cdnPath', 'https://hhhh.aaaa.com.cn');
}
}();
Vue.prototype.$_cPath = function (path) {
const reg = /^(http|ftp|https):\/\//;
const regStatic = /^static\//;
if (!path) {
return ''
} else {
if (!reg.test(path)) {
if (regStatic.test(path)) {
return path
}
let cdnDomain = sessionStorage.getItem('cdnPath');
if (cdnDomain !== null) {
return cdnDomain + path
}
return path
}
return path
}
}
}
export default CdnPath
上一篇:mysql索引sql优化方法、步骤和经验


下一篇:Android 在线更新apk