vue create 新建项目选项

一 . 安装 vue cli

npm install -g @vue/cli

二 . 创建项目 vue create ‘项目名’

vue create hello-world
  • 1、选择 Manually select features (自选项目配置)
Vue CLI v3.1.3
? Please pick a preset: Manually select features
? Check the features needed for your project: (Press <space> to select, <a> to toggle all, <i> to invert s
election)
>(*) Babel   //ES6转ES5
 ( ) TypeScript   //JS超集
 ( ) Progressive Web App (PWA) Support   //渐进式Web应用
 (*) Router  //路由
 ( ) Vuex  //状态管理
 (*) CSS Pre-processors  //CSS预处理
 (*) Linter / Formatter   //规范类型
 ( ) Unit Testing  //测试
 ( ) E2E Testing  //测试
  • 2、是否使用history模式的路由 选择 “N” 或者 “Y”.
Vue CLI v3.1.3
? Please pick a preset: Manually select features
? Check the features needed for your project: Babel, Router, CSS Pre-processors, Linter
? Use history mode for router? (Requires proper server setup for index fallback in production) (Y/n)
  • 3、CSS预处理器选择
Vue CLI v3.1.3
? Please pick a preset: Manually select features
? Check the features needed for your project: Babel, Router, CSS Pre-processors, Linter
? Use history mode for router? (Requires proper server setup for index fallback in production) Yes
? Pick a CSS pre-processor (PostCSS, Autoprefixer and CSS Modules are supported by default): (Use arrow ke
ys)
> Sass/SCSS
  Less
  Stylus
  • 4、选择哪个ESLint自动化代码格式化检测
Vue CLI v3.1.3
? Please pick a preset: Manually select features
? Check the features needed for your project: Babel, Router, CSS Pre-processors, Linter
? Use history mode for router? (Requires proper server setup for index fallback in production) Yes
? Pick a CSS pre-processor (PostCSS, Autoprefixer and CSS Modules are supported by default): Sass/SCSS
? Pick a linter / formatter config: (Use arrow keys)
> ESLint with error prevention only
  ESLint + Airbnb config
  ESLint + Standard config
  ESLint + Prettier
  • 5、选择语法检查的时期
Vue CLI v3.1.3
? Please pick a preset: Manually select features
? Check the features needed for your project: Babel, Router, CSS Pre-processors, Linter
? Use history mode for router? (Requires proper server setup for index fallback in production) Yes
? Pick a CSS pre-processor (PostCSS, Autoprefixer and CSS Modules are supported by default): Sass/SCSS
? Pick a linter / formatter config: Standard
? Pick additional lint features: (Press <space> to select, <a> to toggle all, <i> to invert selection)
>(*) Lint on save  //语法检查配置文件保存时检查
 ( ) Lint and fix on commit  //文件提交时检查
  • 6、配置文件的存放位置(推荐独立放置配置文件)
Vue CLI v3.1.3
? Please pick a preset: Manually select features
? Check the features needed for your project: Babel, Router, CSS Pre-processors, Linter
? Use history mode for router? (Requires proper server setup for index fallback in production) Yes
? Pick a CSS pre-processor (PostCSS, Autoprefixer and CSS Modules are supported by default): Sass/SCSS
? Pick a linter / formatter config: Standard
? Pick additional lint features: Lint on save
? Where do you prefer placing config for Babel, PostCSS, ESLint, etc.? (Use arrow keys)
> In dedicated config files  //放独立文件放置
  In package.json  //放package.json里
  • 7、是否保存此预设(选择yes的话下次就可以不用进行配置)
Vue CLI v3.1.3
? Please pick a preset: Manually select features
? Check the features needed for your project: Babel, Router, CSS Pre-processors, Linter
? Use history mode for router? (Requires proper server setup for index fallback in production) Yes
? Pick a CSS pre-processor (PostCSS, Autoprefixer and CSS Modules are supported by default): Sass/SCSS
? Pick a linter / formatter config: Standard
? Pick additional lint features: Lint on save
? Where do you prefer placing config for Babel, PostCSS, ESLint, etc.? In dedicated config files
? Save this as a preset for future projects? (y/N)

三 . 运行

// 切换到项目
cd hello-world  
// 启动项目
npm run serve
  • 21
    点赞
  • 57
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
### 回答1: 为了新建一个 Vue 项目,我们首先需要确保已经安装了 Node.js 和 npm,因为这两个工具是构建和运行 Vue 项目所必须的。 1. 打开命令行工具,使用以下命令安装 Vue CLI: ``` npm install -g @vue/cli ``` 2. 创建一个新的 Vue 项目 使用以下命令创建一个新的 Vue 项目。其中,`my-project` 是你想要为该项目设置的名称。 ``` vue create my-project ``` 3. 运行项目 创建项目后,进入该项目目录,启动开发服务器以运行项目: ``` cd my-project npm run serve ``` 此时,你可以在浏览器中访问 http://localhost:8080/,就可以看到运行中的 Vue 项目了。 如果你需要构建项目以生成生产环境代码,则运行以下命令: ``` npm run build ``` 这将生成一个 `dist` 文件夹,里面包含了静态文件,可以直接在服务器上进行部署。 ### 回答2: 新建一个 Vue 项目的步骤如下: 1. 在命令行中使用 Vue CLI 创建一个新项目; 2. 在配置选项中选择需要的选项,比如项目名称、使用的模板、babel、css预设等; 3. 在创建过程中可以选择是否使用npm 或者 yarn 进行安装依赖包,也可以使用cnpm 安装; 4. 创建完成后,在命令行中输入命令npm run serve可以运行项目; 5. 在浏览器中访问localhost:8080(默认端口号),即可查看项目; 6. 在项目中可以使用Vue CLI提供的帮助语句和工具,来辅助进行开发和构建。 总之,创建一个Vue项目其实很简单,只要按照上述步骤操作即可。同时,对于想要深入学习Vue的同学们,不妨试着做一些小项目,从而加深自己对Vue框架的掌握和理解。 ### 回答3: 新建Vue项目可以通过Vue CLI来实现。首先需要安装Vue CLI,可以通过npm命令进行安装:npm install -g @vue/cli。 安装完成后,可以在命令行中输入vue create <project-name>来新建Vue项目。其中,<project-name>为项目名称,可以根据实际情况进行命名。 在新建项目的过程中,可以选择使用默认设置或者手动配置选项。手动配置选项包括选择所需的特性、添加插件等,可以按需选择。 新建完成后,可以通过npm run serve命令来启动开发服务器,实现实时预览和热重载功能。同时,可以进行开发和调试工作。在开发完成后,可以通过npm run build命令来进行打包和构建,生成用于生产环境部署的静态文件。 除了Vue CLI,也可以选择其他工具来新建Vue项目,例如使用Webpack等构建工具进行手动配置。但Vue CLI提供了一系列的优秀特性和插件,可以极大地提高开发效率和开发质量,并且具有良好的用户体验和社区支持。 总之,新建Vue项目需要掌握一定的技术和工具,可以借助Vue CLI等工具进行快速构建和开发,实现高质量的Vue应用程序。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值