首页 > 解决方案 > 如何为 Vue CLI 3 项目设置虚拟主机

问题描述

我希望能够从而http://pbdev不是访问我的 Vue 项目localhost:8080。我熟悉在 Apache 中创建虚拟主机,但我不清楚如何使用 Vue CLI 3 项目来做到这一点。

到目前为止,我已将其放入/etc/hosts

# Vue Hosts
127.0.0.1:8080  pbdev

我把它放进去vue.config.js

module.exports = {
  lintOnSave: false,
  devServer: {
    host: 'pbdev',
    port: 8080,
    https: false
  }
}

我收到以下错误:

INFO  Starting development server...
10% building modules 1/1 modules 0 activeevents.js:167                            
  throw er; // Unhandled 'error' event
  ^

Error: getaddrinfo ENOTFOUND pbdev
  at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26)
Emitted 'error' event at:
  at GetAddrInfoReqWrap.doListen [as callback] (net.js:1505:12)
  at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:17)

有谁知道我做错了什么?

标签: webpackvue.jsvue-clivue-cli-3

解决方案


在里面:8080/etc/hosts问题,只是做127.0.0.1 pbdev

祝你快乐!


推荐阅读