最近项目遇到这个问题,如图
访问系统是一直转圈圈,然后显示网络连接超时。
后来上网查看到这样一篇文章解决cdn.jsdelivr.net无法访问
笔者准备尝试下,使用子域名能否解决这个问题,或者使用国内的网站。解决的话会补充后续…
先讲讲为什么要用cdn,在我们的vue项目中,我们去访问系统,浏览器会自动下载vue、vue-router、vuex和axios等一些文件。但是下载的话会比较耗时,因为笔者想打开网页时直接访问别人的资源,用cdn来做会提高访问速度。因此在vue.config.js中写入了
const assetscdn = { // webpack build externals externals: { vue: 'Vue', 'vue-router': 'VueRouter', vuex: 'Vuex', axios: 'axios' }, css: [], // https://unpkg.com/browse/vue@2.6.10/ js: [ '//cdn.jsdelivr.net/npm/vue@2.6.10/dist/vue.min.js', '//cdn.jsdelivr.net/npm/vue-router@3.1.3/dist/vue-router.min.js', '//cdn.jsdelivr.net/npm/vuex@3.1.1/dist/vuex.min.js', '//cdn.jsdelivr.net/npm/axios@0.21.1/dist/axios.min.js', // '//cdnjs.cloudflare.com/ajax/libs/vue/2.6.11/vue.js', // '//unpkg.com/vue-router@3.3.4/dist/vue-router.js', // '//cdn.bootcdn.net/ajax/libs/vuex/3.1.0/vuex.min.js', // '//unpkg.com/axios@0.19.2/dist/axios.min.js', '//cdn.bootcdn.net/ajax/libs/nprogress/0.2.0/nprogress.js', '//cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js', '//cdnjs.cloudflare.com/ajax/libs/js-cookie/2.2.1/js.cookie.min.js', ] }
但是有时候会出现Failed to load resource: net::ERR_CONNECTION_TIMED_cdn.jsdelivr.net/npm/vue@2.6.10/dist/vue.min.js'这个错误。后续思考如何解决,今天先记录到这里
后续来了,把cdn.jsdelivr.net换成国内的域名就ok,但是需要自己去找对应的路径,这里改为这几个,加入zhimg,改为国内地址
'//cdnjs.cloudflare.com/ajax/libs/vue/2.6.11/vue.js',
'//unpkg.zhimg.com/vue-router@3.3.4/dist/vue-router.js',
'//cdn.bootcdn.net/ajax/libs/vuex/3.1.0/vuex.min.js',
'//unpkg.zhimg.com/axios@0.19.2/dist/axios.min.js',
原文链接:https://blog.csdn.net/cozy666/article/details/135270929?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522171836857716800188575975%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=171836857716800188575975&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~times_rank-17-135270929-null-null.nonecase&utm_term=cdn%E7%B3%BB%E7%BB%9F
原创文章,作者:优速盾-小U,如若转载,请注明出处:https://www.cdnb.net/bbs/archives/33288