May 20, 2021 WeChat Mini Program Development Document
Code snippets are small, shareable projects that can be used to share development experiences for small programs and games, demonstrate the use of components and APIs, re-create development issues, and more. S haring a snippet gets a link that everyone who owns can import in the tool. I f a clickable link to a web page points to a shared link, clicking on the link will automatically open the tool to enter the snippet import page. Use the latest version of the developer tool to tap this experience to import snippets of code.
In the interface of the tool selection project, you can select the snippet page card on the right to see all the local code snippets, and in the lower right corner you can click Create code snippets.
Creating a snippet requires filling in the code snippet name and storing the catalog locally. A ppID is not required and needs to be completed if you need to demonstrate actions that rely on appID. If the storage directory is empty, you can select a quick launch template for small programs, games, and so on below.
Once the information is filled in correctly, click Create to create and open the snippet.
The main interface of code snippets differs from normal projects in the following key areas:
Click the Sharing button on the toolbar to open the flow of sharing code snippet, and you need to fill in the following in sharing information:
Sharing applet code snippet is a maximum size of 100KB, and the small game code fragment is up to 200KB.
After the sharing is successful, the sharing link will be displayed. You can copy to other developers. Other developers can import the import code snippet and paste the link.
分享的链接除了可以粘贴到导入页导入外,还可以设置为可点击的链接。如果 html <a> 标签的 href 属性设置为分享的链接,如 <a href="wechatide://minicode/76b799966b6ead1837edac517cc02e02" rel="external nofollow" target="_blank" >代码片段示例</a>,则用户点击此链接时会自动打开工具进入代码片段导入页,最后点击导入即可完成导入。在开发者社区发帖时,如果想要提供 demo 示例,如果想要提供 demo 示例,可以插入一个链接为代码片段分享链接的超链接。
In the lower right corner of the page where you select the snippets, you can open the import page by clicking Import to enter the import page, or by clicking Import code snippets under the Items tab on the menu bar. Y ou'll need to fill in a share link or code snippet ID when you import. The last part of the link is the ID of the snippet, such as wechatide://minicode/76b799966b6ead1837edac517cc02e02's ID is 76b799966b6ead1837edac517cc02e02.
You can choose to store the catalog and appID when you import. The storage directory defaults to a temporary folder.