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
After the container is started Log in to admin fi...
Table of contents 1. MySQL data backup 1.1, mysql...
Table of contents 1. Automatic installation using...
This script can satisfy the operations of startin...
Problem Description After installing workstations...
Preface The previous article introduced the insta...
1. Application of multimedia in HTML_falsh animat...
This article shares the specific code of the WeCh...
I followed the tutorial on W3school. I think the t...
Table of contents 1. About JavaScript 2. JavaScri...
Two examples of the use of the a tag in HTML post...
[Problem description] Our production environment ...
Table of contents 1. Basic understanding of React...
Today, let's talk about how to use js to achi...
Table of contents Introduction Description Naming...