[WeChat Mini Program] Use vscode to develop mini program projects

Plug-in installation for WeChat applet development tools (code support, syntax highlighting)

1. Install the easy compile extension

Insert image description here

2. Environment configuration

If we don’t want to write wxss, but want to write less and scss, but less and scss were compiled into css before, then we can configure the settings in the vscode environment.

"easycompile.less": {
    
    
     "outExt": ".wxss"
},
 "easycompile.sass": {
    
    
     "outExt": ".wxss"
},

Insert image description here

3. Format files such as wxml

  • Download plugin
    Insert image description here
  • I want to take advantage of the prettier function and vscode environment configuration settings that I am already familiar with⬇
// 想要对wxml等文件进行格式化操作,想利用本身已经熟悉的prettier功能
"[wxml]": {
    
    
     "editor.defaultFormatter": "esbenp.prettier-vscode"
     },
     "[wxss]": {
    
    
     "editor.defaultFormatter": "esbenp.prettier-vscode"
     },
     "prettier.documentSelectors": ["**/*.wxml", "**/*.wxss"]

Finally, in the root directory of the project, add the .prettierrc configuration file

{
    
    
  "overrides": [
    {
    
    
      "files": "*.wxml",
      "options": {
    
    
        "parser": "html"
      }
    },
    {
    
    
      "files": "*.wxss",
      "options": {
    
    
        "parser": "css"
      }
    }
  ]
}

Although vscode can be used to develop small program code, "WeChat Developer Tools" cannot be separated because it needs to be used for debugging and viewing operations.

Thanks for the reference

Guess you like

Origin blog.csdn.net/m0_64373473/article/details/132983958