美文网首页
Vue CLI(4) 创建项目

Vue CLI(4) 创建项目

作者: 浅诞厘汨栽 | 来源:发表于2020-04-30 08:35 被阅读0次

    创建 vue 项目

    创建一个新项目,运行:

    vue create hello-world
    

    警告
    如果你在 windows 系统中通过 minTTY 使用 Git Bash,这个交互弹窗不会有效果。你必须使用 winpty vue.cmd create hello-world 来运行命令。如果你仍然想使用 vue create hello-world 语法,你可以通过在你的 ~/.bashrc 文件中添加增加一行内容来设置命令的别名:alias vue='winpty vue.cmd'。设置后你将需要重启你的 Git Bash 终端会话来更新 bashrc 文件。

    你将被提示需要进行预设。你可以选择一个有 Babel+ESLint 的默认预设,或者通过选择“Manuall select features”来选择你需要的功能


    image.png 默认的安装非常有利于快速创建一个新项目的原型,然而安装手册提供了更多的选择,一般提供给更多产品导向的项目。 image.png

    如果你手动选择功能细节,在弹窗的底部你也有保存你的选项作为预设的选项,这样你之后就可以重复使用。下一节我们将讨论预设和插件。

    ~/.vuerc
    保存的预设被存储在你的用户 home 目录里面一个名为 .vuerc 的 json 文件中。如果你想修改保存的预设/选项,可以修改该文件。
    在项目创建过程中,你也许被弹窗提示选择一个更好的包管理工具,或者使用淘宝的 npm 注册镜像进行更快的依赖安装。你的选择也将被保存到 ~/.vuerc

    vue create 命令也有一系列选项,你可以通过运行以下命令来摸索:

    vue create --help
    
    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
      -g, --git [message|false]       Force / skip git initialization, optionally specify 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(4) 创建项目

          本文链接:https://www.haomeiwen.com/subject/pbpawhtx.html