vue项目中获取cdn域名插件
程序员文章站
2022-05-25 18:27:45
import axios from 'axios' let CdnPath = {} CdnPath.install = function (Vue, options) { Vue.prototype.$_cdnDomain = function () { if (process.env.NODE_... ......
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
上一篇: VMware安装CentOS后网络设置
下一篇: 登录页面登录框居中