如何将 `vue ui` 绑定到另一个 IP? (vue-cli 3)

How can I bind `vue ui` to another IP? (vue-cli 3)

我在 docker 中使用 vue-cli,需要将服务绑定到 LAN IP,或者绑定到 0.0.0.0 才能访问它们 'locally'。

我预计 --host 0.0.0.0,但没有。

$ vue ui Starting GUI... Ready on http://localhost:8000

$ vue ui -h Usage: ui [options] start and open the vue-cli ui Options: -p, --port <port> Port used for the UI server (by default search for awailable port) -D, --dev Run in dev mode --quiet Don't output starting messages --headless Don't open browser on start and output port -h, --help output usage information

我正在使用 Vue.js inside a Vagrant 实例进行开发,最初遇到了同样的问题。

貌似在vue-cli 3.1.0版本中添加了-H / --host选项: https://github.com/vuejs/vue-cli/pull/2568

$ vue --version
3.1.3

$ vue ui -h
Usage: ui [options]

start and open the vue-cli ui

Options:
  -H, --host <host>  Host used for the UI server (default: localhost)
  -p, --port <port>  Port used for the UI server (by default search for available port)
  -D, --dev          Run in dev mode
  --quiet            Don't output starting messages
  --headless         Don't open browser on start and output port
  -h, --help         output usage information

$ vue ui -H 0.0.0.0
  Starting GUI...
  Ready on http://0.0.0.0:8000

这解决了我的问题。