vue项目部署至服务器报错vue is not defined,有几个文件访问不到:

 刚开始不知道,找不着文件,后面搜到了cdn。应该是cdn挂了,替换了另一个cdn网站:bootcdn.cn

本地打包部署系统就通了,关于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
    '//cdn.bootcdn.net/ajax/libs/vue/2.6.10/vue.min.js',
    '//cdn.bootcdn.net/ajax/libs/vue-router/3.1.3/vue-router.min.js',
    '//cdn.bootcdn.net/ajax/libs/vuex/3.1.1/vuex.min.js',
    '//cdn.bootcdn.net/ajax/libs/axios/0.19.0/axios.min.js'
    //原来的cdn
    // '//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.19.0/dist/axios.min.js'
  ]
}

Logo

前往低代码交流专区

更多推荐