wechat mini apps-Create a code snippet - 书目录

wechat mini apps-Create a code snippet

Code snippets are small, shareable projects that can be used to share the development experience of applets and mini-games, the use of presentation components and APIs, recurring development issues, and more. Sharing the code snippet will get a link, and anyone who has this shared link can import this code snippet in the tool. If a clickable link to a webpage points to a share link, clicking on the link will automatically open the tool to the code snippet import

Create a code snippet

In the interface of the tool selection item, the code fragment page card can be selected on the right side to view all the local code snippets, and in the lower right corner, click to create a code snippet.

Create code snippet needs to fill in the code snippet name, local storage directory. AppID is not required. If you need to demonstrate the operation that depends on AppID, you need to fill it out. If the storage directory is an empty directory, you can select quick launch templates for applets, mini-games, etc. below.

After the information is filled in correctly, click Create to finish creating and opening the code snippet.

Code fragment main interface

The main interface of the code fragment and the general project are mainly the following differences:

1 No upload, Tencent cloud, and application for test reports
2 The details page will show the last shared link and can be copied in one click
3 The quick start template of the code segment is different from the quick start template of the common project, and the size is smaller and the function is more streamlined

Share code snippet

Click the Share button on the toolbar to open the process for sharing the code snippet. You need to fill in the following information in the sharing information:

1 Project Description: Briefly describes the function and purpose of this code snippet
2 Whether AppID is required: If yes, developers will suggest to fill in AppID to run code snippet completely when importing code snippet
3 Minimum library version: The debug base library of the detail page will not be lower than the specified version when the developer opens the imported code snippet

The maximum size of the shared applet code segment is 100KB, and the maximum size of the minigame code segment is 200KB.

After the sharing is successful, the sharing link will be displayed, which can be copied and shared with other developers. Other developers can import the code by selecting the import code snippet and pasting the link in the tool.

The shared link can be set as a clickable link in addition to the import on the import page. If the href attribute of the html <a> tag is set to a shared link, such as the <a href=”wechatide://minicode/76b799966b6ead1837edac517cc02e02″>code snippet example</a>, the user will automatically open the tool access code when clicking this link Fragment import page, and finally click import to complete the import. When posting in the developer community, if you want to provide a demo sample, if you want to provide a demo sample, you can insert a link that links the code snippet to share the link.

Import code snippet

In the lower right corner of the page where the code snippet is selected, you can click Import to enter the import page, or click the Import code snippet under the Project tab on the menu bar to open the import page. You need to fill in the share link or code snippet ID when importing. The last part of the link is the ID of the code snippet. For example, the ID of wechatide://minicode/76b799966b6ead1837edac517cc02e02 is 76b799966b6ead1837edac517cc02e02.

You can choose to store the directory and AppID when importing. The default directory is in the temporary folder.