Vue3項目的3種創(chuàng)建方式代碼示例
使用 vue-cli 創(chuàng)建
vue-cli4.x是基于webpack4的,vue-cli5.x是基于webpack5的
## 安裝或者升級你的@vue/cli npm install -g @vue/cli ## 創(chuàng)建 vue create vue3_cli //vue_stduy_cli為自定義文件名
根據(jù)我們的需求選擇對應的模板
Vue CLI v5.0.8 ? Please pick a preset: > Default ([Vue 3] babel, eslint) Default ([Vue 2] babel, eslint) Manually select features
使用crate-vite 創(chuàng)建
官方文檔:https://vitejs.cn/vite3-cn/guide/#scaffolding-your-first-vite-project
crate-vite是vite官方提供的官方腳手架,可以創(chuàng)建vue、react等框架的項目模板。
使用npm
npm create vite@latest
npm create 是 npm init 的別名 npm init vite@latest同樣生效
使用 Yarn:
yarn create vite
使用 PNPM:
pnpm create vite
根據(jù)我們的需求選擇對應的模板
PS C:\Users\Administrator\Desktop> npm create vite@latest √ Project name: ... vite-project ? Select a framework: ? - Use arrow-keys. Return to submit. > Vanilla Vue React Preact Lit Svelte Others
使用 create-vue創(chuàng)建
https://cn.vuejs.org/guide/quick-start.html#creating-a-vue-application
這是vue官方提供的vue項目構建工具,基于vite
npm init vue@latest
npm create 是 npm init 的別名 npm create vue@latest同樣生效
? Project name: … <your-project-name> ? Add TypeScript? … No / Yes ? Add JSX Support? … No / Yes ? Add Vue Router for Single Page Application development? … No / Yes ? Add Pinia for state management? … No / Yes ? Add Vitest for Unit testing? … No / Yes ? Add Cypress for both Unit and End-to-End testing? … No / Yes ? Add ESLint for code quality? … No / Yes ? Add Prettier for code formatting? … No / Yes Scaffolding project in ./<your-project-name>... Done.
全選Yes后的模板目錄結構
├─ cypress
├─ public
│ └─ favicon.ico
├─ src
│ ├─ App.vue
│ ├─ assets
│ ├─ components
│ ├─ main.ts
│ ├─ router
│ │ └─ index.ts
│ ├─ stores
│ │ └─ counter.ts
│ └─ views
│ ├─ AboutView.vue
│ └─ HomeView.vue
├─ tsconfig.app.json
├─ tsconfig.config.json
├─ tsconfig.json
├─ tsconfig.vitest.json
└─ vite.config.ts
├─ .eslintrc.cjs
├─ .gitignore
├─ .prettierrc.json
├─ cypress.config.ts
├─ env.d.ts
├─ index.html
├─ package.json
總結
到此這篇關于Vue3項目的3種創(chuàng)建方式的文章就介紹到這了,更多相關Vue3項目創(chuàng)建方式內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
Vuex中如何getters動態(tài)獲取state的值
這篇文章主要介紹了Vuex中如何getters動態(tài)獲取state的值,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-08-08從零開始Vue3數(shù)據(jù)交互之promise用法詳解
這篇文章主要介紹了Axios的基本使用,包括異步編程的基礎知識,如Promise的介紹、特點和基本用法,以及如何使用then、catch和async/await來處理異步操作,文中通過代碼介紹的非常詳細,需要的朋友可以參考下2025-02-02解決vue-cli單頁面手機應用input點擊手機端虛擬鍵盤彈出蓋住input問題
今天小編就為大家分享一篇解決vue-cli單頁面手機應用input點擊手機端虛擬鍵盤彈出蓋住input問題,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-08-08Element-ui中的Cascader級聯(lián)選擇器基礎用法
這篇文章主要為大家介紹了Element-ui中的Cascader級聯(lián)選擇器基礎用法,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2023-06-06