webpack - 为什么 vue-cli 有两个 vuejs 启动命令?
问题描述
我在网上查找并遇到了两个不同的运行命令,其奇怪的原因是例如 React 有 command 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 create
或vue ui
引导应用程序。对于 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/ 。
推荐阅读
- javascript - 无法遍历音节并将其取回我的 CMS
- sql - SQL Server 中的随机选择
- crystal-reports - 适用于 Visual Studio 2017 的水晶报表
- azure - VSTS - Azure 端点问题
- java - 如何将 UUID 插入 RAW(16) 列
- java - 如何使用 selenium 和 java 在关键字驱动框架中的任何方法中添加验证
- xcode - Xcode 9 在 clean 上执行自定义命令
- html - asp.net MVC 中的 html 音频 currentTime 和 FileResult
- c++ - 如何确定迭代器在c ++模板函数中指向的对象的类型?
- keras - 这个 Keras 模型在创建时工作,但在加载时失败。怀疑张量分裂