Home > WeChat Applet > Mini Program Development > WeChat applet absolute path require

WeChat applet absolute path require

hzc
Release: 2020-06-05 09:39:33
forward
4401 people have browsed it

Before referring to the above article, you can implement the introduction of absolute paths, but in vscode, the require function cannot automatically prompt the path and the require module cannot automatically prompt

In order to solve this problem

1. Create the jsconfig.json file in the root directory

{  "compilerOptions": {   
         "target": "ES6", 
          "baseUrl": ".",  
          "paths": {  
             "/*": ["./*"]
            }
     }
}
Copy after login

2. When using the require function js Add

const app = getApp();
(function () { require = app.require; })();
Copy after login

at the beginning of the file. 3. Use

const CommonApi = require("/api/common");  
//可自动提示路径CommonApi.CallApi1(); //可以自动提示出方法 可配合d.ts食用
Copy after login

Recommended tutorial: "WeChat Public Account"

The above is the detailed content of WeChat applet absolute path require. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template