安装 Vue Cli
npm install -g @vue/cli
创建项目
vue create hello-world (hello-world为我的项目名)
3
? Please pick a preset:
default (babel, eslint)
> Manually select features //选这个
4
? Please pick a preset: Manually select features
? Check the features needed for your project:
(*) Babel
( ) TypeScript
( ) Progressive Web App (PWA) Support
>(*) Router
( ) Vuex
( ) CSS Pre-processors
( ) Linter / Formatter
( ) Unit Testing
( ) E2E Testing
5
Use history mode for router? (Requires proper server setup for index fallback in production) (Y/n) n
6
? Where do you prefer placing config for Babel, PostCSS, ESLint, etc.? (Use arrow keys)
> In dedicated config files //选择个
In package.json
7
? Save this as a preset for future projects? (y/N) n
8提示信息为:
cd hello-world
npm run serve ("serve": "vue-cli-service serve")//行家,你懂的
先不慌着执行命令,先安装vant插件,在执行npm run serve
9 重点:安装vant
npm i vant
话外题
Vant Touch Emulator 在桌面端上模拟移动端 touch 事件,实现方式来自于 hammerjs/touchemulator.
Install
NPM
npm i @vant/touch-emulator -S
YARN
yarn add @vant/touch-emulator
使用指南
直接在代码中引入模块即可,模块会自动完成初始化并生效
import '@vant/touch-emulator';
CDN 引入
<script src="https://cdn.jsdelivr.net/npm/@vant/touch-emulator"></script>