创建项目
vue-cli创建
$npm install -g @vue/cli
$vue --version
@vue/cli 4.5.15
$vue create my-project
然后的步骤:
- Please pick a preset
选择 Manually select features - Check the features needed for your project
选择上TypeScript,特别注意点空格是选择,点回车是下一步 - Choose a version of Vue.js that you want to start the project with
选择 3.x (Preview) - Use class-style component syntax
直接回车 - Use Babel alongside TypeScript
直接回车 - Pick a linter / formatter config
直接回车 - Use history mode for router?
直接回车 - Pick a linter / formatter config
直接回车 - Pick additional lint features
直接回车 - Where do you prefer placing config for Babel, ESLint, etc.?
直接回车 - Save this as a preset for future projects?
直接回车
vite创建
执行以下命令创建项目
$npm init vite-app <project-name>
$cd <project-name>
$npm install
$npm run dev
入口文件为
src/main.ts
setup
vue3的setup就是data与methods和结合