zoukankan      html  css  js  c++  java
  • 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
    
    
  • 相关阅读:
    登录注册页面切换
    LINUX系统日常使用命令
    find命令详解
    ssh命令详解
    tar命令详解
    route命令详解
    uname命令详解
    ps命令详解
    df命令详解
    virsh命令详解
  • 原文地址:https://www.cnblogs.com/linjiu0505/p/10578244.html
Copyright © 2011-2022 走看看