• vue-cli3.0相关的坑


    vue-cli3.0相对比vue-cli2.0少了 vue-build.js vue-config.js

    vue-cli2.0 运行命令 npm run dev
    vue-cli3.0 运行命令 npm run serve

    vue-cli3.0 要自己在项目根目录下配置 vue-config.js

    vue-cli3.x 新特性及踩坑记

    
    module.exports = {
      // baseUrl  type:{string} default:'/' 
      // 将部署应用程序的基本URL
      // 将部署应用程序的基本URL。
      // 默认情况下,Vue CLI假设您的应用程序将部署在域的根目录下。
      // https://www.my-app.com/。如果应用程序部署在子路径上,则需要使用此选项指定子路径。例如,如果您的应用程序部署在https://www.foobar.com/my-app/,集baseUrl到'/my-app/'.
    
      baseUrl: './',
    
    
      // outputDir: 在npm run build时 生成文件的目录 type:string, default:'dist'
    
      outputDir: 'dist',
    
      // pages:{ type:Object,Default:undfind } 
    /*
    构建多页面模式的应用程序.每个“页面”都应该有一个相应的JavaScript条目文件。该值应该是一
    个对象,其中键是条目的名称,而该值要么是指定其条目、模板和文件名的对象,要么是指定其条目
    的字符串,
    注意:请保证pages里配置的路径和文件名 在你的文档目录都存在 否则启动服务会报错的
    */
      // pages: {
          // index: {
              // entry for the page
              // entry: 'src/index/main.js',
              // the source template
              // template: 'public/index.html',
              // output as dist/index.html
              // filename: 'index.html'
          // },
          // when using the entry-only string format,
          // template is inferred to be `public/subpage.html`
          // and falls back to `public/index.html` if not found.
          // Output filename is inferred to be `subpage.html`.
          // subpage: 'src/subpage/main.js'
      // },
    
      //   lintOnSave:{ type:Boolean default:true } 问你是否使用eslint
      lintOnSave: true,
      // productionSourceMap:{ type:Bollean,default:true } 生产源映射
      // 如果您不需要生产时的源映射,那么将此设置为false可以加速生产构建
      productionSourceMap: false,
      // devServer:{type:Object} 3个属性host,port,https
      // 它支持webPack-dev-server的所有选项
     
      devServer: {
    
          port: 8085, // 端口号
          host: 'localhost',
          https: false, // https:{type:Boolean}
          open: true, //配置自动启动浏览器
          // proxy: 'http://localhost:4000' // 配置跨域处理,只有一个代理
          proxy: {
              '/api': {
                  target: 'https://apiv2.pinduoduo.com',
                  ws: true,
                  changeOrigin: true
              },
              '/foo': {
                  target: '<other_url>'
              }
          },  // 配置多个代理
      }
    }
    

    vue在用HBuilder打包后 app启动一片空白 3.0里面的baseUrl 改成 baseUrl: './'

    如果你安装了vue-cli3.0却要用cli2.0的话那么你需要全局安装一个桥接工具 npm install -g @vue/cli-init
    另外使用HBuilder将项目打包的时候发现自己的接口里面的数据请求不到,其它静态资源正常显示。那是因为在开发阶段浏览器需要解决跨域问题使用了反向代理,如果打包app需要将代理注释,axios请求地址改为绝对路径

    原文地址:https://segmentfault.com/a/1190000016964485

  • 相关阅读:
    Qtranslate是Win10系统的一款非常小众的翻译神器,真的是办公人员利器
    大文件查找软件(WizTree) v3.37 ---非常快
    DirPrintOK --- 将文件以树的形式列出、可导出到excel、html文件,用于整理电脑的文件,非常好用
    Linux五大类常用命令
    Android pm list 命令查看手机安装的apk信息
    Android adb命令列出当前设备所有apk安装的路径和包名
    Win10 Python2.7.6 如何使用pip命令?如何离线安装第三方模块?PyCharm设置Python2.7.6,、wxPython安装
    证件照在线免费移除背景或更换背景
    Ubuntu wps办公软件快捷键
    根据书籍的ISBN号查询书籍信息
  • 原文地址:https://www.cnblogs.com/lalalagq/p/10124632.html
Copyright © 2020-2023  润新知