为什么vue-cli 有两个vuejs 启动命令?

Why are there two vuejs start commands for vue-cli?

我在网上查找并遇到了两个不同的 运行 命令,其奇怪的原因是 React 例如有命令 create-react-app <name of app>,但是对于 vue-cli 我找到了这两个命令 vue create <name of app>vue init webpack <name of app>

我在 运行 执行这两个命令后仔细检查,发现它们都包含 webpack,但结构不同。第一个预装了 vuex,而另一个没有。第二个命令有很多额外的 devDependencies。

对于包含 vue-router 和 vuex 的多页面 vuejs 应用程序,哪个命令是合适的命令我有点困惑。

对于 Vue CLI v3,您可以使用 vue createvue ui 来 bootstrap 应用程序。对于 Vue CLI v2,您使用 vue init.

如果您安装了 Vue CLI v3,您仍然可以使用 vue init,尽管它被认为是旧版 API:

$ vue --version
3.0.0

$ vue init

  Usage: init [options] <template> <app-name>

  generate a project from a remote template (legacy API, requires @vue/cli-init)

  Options:

    -c, --clone  Use git clone when fetching remote template
    --offline    Use cached template
    -h, --help   output usage information

$ vue create

  Usage: create [options] <app-name>

  create a new project powered by vue-cli-service

  Options:

    -p, --preset <presetName>       Skip prompts and use saved or remote preset
    -d, --default                   Skip prompts and use default preset
    -i, --inlinePreset <json>       Skip prompts and use inline JSON string as preset
    -m, --packageManager <command>  Use specified npm client when installing dependencies
    -r, --registry <url>            Use specified npm registry when installing dependencies (only for npm)
    -g, --git [message]             Force git initialization with initial commit message
    -n, --no-git                    Skip git initialization
    -f, --force                     Overwrite target directory if it exists
    -c, --clone                     Use git clone when fetching remote preset
    -x, --proxy                     Use specified proxy when creating project
    -b, --bare                      Scaffold project without beginner instructions
    -h, --help                      output usage information

Vue CLI 在版本 3 中是稳定的,所以我会确保你已经安装了它,并使用 vue create 命令或 vue ui 命令。 vue ui 仍处于测试阶段,我还没有尝试过,但看起来不错。您可以通过 CLI 网站了解更多信息:https://cli.vuejs.org/.