Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Cheatsheets for experienced Vue developers getting started with TypeScript

License

NotificationsYou must be signed in to change notification settings

typescript-cheatsheets/vue

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 

Repository files navigation

Cheatsheets for experienced Vue developers getting started with TypeScript

Section 1: Setup

Prerequisites

  1. A good understanding ofVue.js
  2. Read the TypeScript support section in the Vue docs2.x |3.x

Vue + TypeScript Starter Kits

  1. Using theVue CLI , you can select theTypeScript plugin to be setup in a new a Vue project.
# 1. Install Vue CLI, if it's not already installednpm install --global @vue/cli# 2. Create a new project, then choose the "Manually select features" optionvue create<my-project-name>
  1. Vite is a new build tool by Evan You. It currently only works with Vue 3.x but supports TypeScript out-of-the-box.

⚠ Currently in beta. Do not use in production.

npm init vite-app<project-name>cd<project-name>npm installnpm run dev

Section 2: Getting Started

Recommendedts.config setup

note:strict:true stricter inference for data properties onthis. If you do not use it,this will always be treated asany

// tsconfig.json{"compilerOptions": {"target":"esnext","module":"esnext","strict":true,"moduleResolution":"node"    }}

Usage in.vue files

Addlang="ts" to the script tag to declare TS as thelang used.

<scriptlang='ts'>...</script>

In Vue 2.x you need to define components withVue.component orVue.extend:

<scriptlang="ts">import Vue from "vue";export default Vue.extend({// type inference enabledname:"HelloWorld",props:{msg:String}});</script>

In Vue 3.x you can usedefineComponent to get type inference in Vue component options

import{defineComponent}from'vue';constComponent=defineComponent({// type inference enabled});

Other Vue + TypeScript resources

About

Cheatsheets for experienced Vue developers getting started with TypeScript

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors3

  •  
  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp