Because I have always used vscode to develop front-end projects, now some small programs or h5 projects are developed using uniapp. After experiencing hbuiler for a period of time, I still think vscode is good. The following shares some configurations I developed using vscode. These include uniapp component syntax prompts, uniapp code prompts, and automatic code formatting.
1. Install vetur First we need to install the vscode basic vue plugin 2. Install eslint Install 3. Configure vscode's setting.json VSCode extends the settings, click File > Preferences > Settings to open the VSCode configuration file { "files.autoSave": "off", "eslint.validate": [ "javascript", "javascriptreact", "vue-html", { "language": "vue", "autoFix": true } ], "eslint.run": "onSave", "editor.tabSize": 2, "editor.codeActionsOnSave": { "source.fixAll.eslint": true } } The same is true for automatically formatting Vue projects. The above is part of the configuration. Do not delete the original configuration. Different versions of vscode may have slightly different configurations. If there is a problem with any configuration, vscode will prompt you. 4. Create a uniapp project using vue-cli. You need to make sure you have installed vue-cli globally. If not, install vue-cli first. We first select the default template (Typescript) of course you can also choose other templates After the installation is complete, we use vscode to open the project we just created. 5. Install component syntax hints in the project 6. Install 7. Save and automatically format the code You can see that the format of the page is quite messy at this time, which is uncomfortable to look at, and it will not be automatically formatted when saved, so we need to add eslint to the project We can see that some configured js files report errors. We can ignore eslint checks at the beginning and end of these files, such as /* eslint-disable */ const path = require("path"); module.exports = { parser: require("postcss-comment"), plugins: [ require("postcss-import")({ resolve(id, basedir, importOptions) { if (id.startsWith("~@/")) { return path.resolve(process.env.UNI_INPUT_DIR, id.substr(3)); } else if (id.startsWith("@/")) { return path.resolve(process.env.UNI_INPUT_DIR, id.substr(2)); } else if (id.startsWith("/") && !id.startsWith("//")) { return path.resolve(process.env.UNI_INPUT_DIR, id.substr(1)); } return id; }, }), require("autoprefixer")({ remove: process.env.UNI_PLATFORM !== "h5", }), require("@dcloudio/vue-cli-plugin-uni/packages/postcss"), ], }; /* eslint-disable */ The other configured js files are similarly operated. After the configuration is completed, we save the code and it will be automatically formatted. 8. Import the code blocks provided by HBuilderX Download the uni-app code block from github and put it in the .vscode directory under the project directory to have the same code block as HBuilderX. d Code block download address This is the end of this article about how to use vscode to develop uniapp. For more relevant vscode development uniapp 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:
|
<<: The latest super detailed VMware virtual machine download and installation graphic tutorial
>>: The latest super detailed graphic tutorial of installing Kali Linux on virtual machine VMware
There are obvious differences between volume moun...
How to implement the "Set as homepage" ...
The META tag is an auxiliary tag in the head area...
Because li is a block-level element and occupies ...
cellspacing is the distance between cells in the t...
This article example shares the specific code for...
1 Overview System centos8, use httpd to build a l...
Table of contents 1. Responsive principle foundat...
To improve processing power and concurrency, Web ...
After this roll call device starts calling the ro...
Source of the problem: If the slave server is the...
1. Technical points involved vite version vue3 ts...
Table of contents 1. Problem Background 2. What a...
<br />Original source: http://www.a-xuan.cn/...
Table of contents 1. Introduction 2. Back up the ...