【Vue】Vue 3.0(beta)のプロジェクト作成
今回試したバージョンは次の通り
"vue": "^3.0.0-beta.1", "vuex": "^4.0.0-alpha.1"
プロジェクト作成
プロジェクトは通常通りに作成した後に、vue3.0を追加します。
通常通りに作成
vue create <projectname>
選択肢は次のように設定
- Please pick a preset: Manually select features
- Check the features needed for your project: Babel, TS, Vuex, Linter
- Use class-style component syntax? No
- Use Babel alongside TypeScript (required for modern mode, auto-detected polyfills, transpiling JSX)? Yes
- Pick a linter / formatter config: Prettier
- Pick additional lint features: Lint on save
- Where do you prefer placing config for Babel, ESLint, etc.? In dedicated config files
- Save this as a preset for future projects? No
vue 3.0を追加
cd <projectname> vue add vue-next
ただし、npm run serve
するとエラーが出るので修正する。
修正
自分の環境では次のエラーが発生
- node_modules/@vue/runtime-core/dist/runtime-core.d.ts
- src/shims-tsx.d.ts
- src/store/index.ts
d.tsの型チェックを無視
tsconfig.json
"compilerOptions": { "skipLibCheck": true ... },
"Vuex."を取り除く
store/index.ts
import { createStore } from 'vuex' export default createStore({ ... });
.vueのVue.extendを取り除く
App.vue, HelloWorld.vue
export default { ... }