Through the development of various front-end frameworks, such as vue3.0, react and angular, the source code of frameworks are all written in ts (typescript), so I feel that the development trend of future medium and large projects is also inseparable from ts. Therefore, I wrote documents using vue combined with ts according to some introductory tutorials, which is suitable for getting started with configuring vue+ts projects. 1. TypeScript is introduced into the old Vue projectnpm install vue-class-component vue-property-decorator --save npm install ts-loader typescript tslint tslint-loader tslint-config-standard --save-dev
// For file plugin configuration, it needs to be written in the configureWebpack object. module.exports = { configureWebpack: { resolve: { extensions: [".ts", ".tsx", ".js", ".json"] }, module: { rules: { test: /\.ts$/, exclude: /node_modules/, enforce: 'pre', loader: 'tslint-loader' }, { test: /\.tsx?$/, loader: 'ts-loader', exclude: /node_modules/, options: appendTsSuffixTo: [/\.vue$/], } } ] } } } Create a Vue+Typescript project from scratch This method is relatively simple. You can create it by simply selecting Custom when creating a project with the command In the second step, just select the above options. Use the space bar to select them in the terminal, and press Enter after selecting. The meanings of the options are as follows: (*) Babel //ES6 to ES5 (*) TypeScript //Using ts ( ) Progressive Web App (PWA) Support //Progressive Web App (*) Router //Routing (*) Vuex //State Management (*) CSS Pre-processors //CSS preprocessing (*) Linter / Formatter //Specification type ( ) Unit Testing //Test ( ) E2E Testing //Test The next step configuration details are as follows: Use class-style component syntax? (Y/n) Do you want to use class-style component syntax? Enter Y and press Enter Use Babel alongside TypeScript (required for modern mode, auto-detected polyfills, trans piling JSX)? (Y/n) Do you use Babel and TypeScript (modern mode, automatic detection of polygon fills, trans required (JSX) Enter Y Enter Use history mode for router? (Requires proper server setup for index fallback in product ion) (Y/n) Do you want to use history routing mode? Enter N and press Enter. Pick a CSS pre-processor (PostCSS, Autoprefixer and CSS Modules are supported by default) I usually choose Sass/SCSS (with node-sass) Pick a linter / formatter config: (Use arrow keys): Select the syntax detection specification. Generally, the first one, ESLint with error prevention only, is the default. However, if you use ts, you can choose TSLint Pick additional lint features: (Press to select, to toggle all, to invert selection) Select Check on Save / Check on Submit Generally, select the first check on save during development Where do you prefer placing config for Babel, PostCSS, ESLint, etc.? (Use arrow keys) Select where to store the configuration information, either separately or in package.json Generally, the first one is selected by default, and the plugin configuration is stored in a separate file Save this as a preset for future projects? (y/N) Do you want to save it as a preset so that you don't have to re-select it next time you create a project? Enter N and press Enter After completing the above options, the project is built successfully, and the project directory is as follows: You need to create the This is the end of this article about the steps to use typescript configuration in vue. For more relevant vue typescript configuration content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: A detailed discussion on detail analysis in web design
Last weekend, a brother project was preparing to ...
HTML-centric front-end development is almost what ...
Implementing carousel with a single DOM node You ...
1.command not found command not found 2. No such ...
Table of contents summary Environment and tool pr...
Students who use Ansible know that Ansible only s...
For front-end developers, ensuring that the code ...
Preface The sleep system function in MySQL has fe...
<br />In the first section of this series, w...
Table of contents App Update Process Rough flow c...
Fast-Linux project address: https://gitee.com/uit...
This article shares the specific code of js+Html ...
Table of contents Introduction How to connect to ...
Detailed explanation of MySQL instance with SSD s...
Preface Previously, static IPs assigned using pip...