Wechat Miniprogram Skill

作者 Gourdbaby36bd11b412117d71b07747ad2fda1115c00afe59无许可证9 个星标收录于 2026年10月9日更新于 2026年10月9日仓库8个月前更新

Expert guidelines for Native WeChat Mini Program development focusing on performance, code size, and native compatibility. Use when developing WeChat Mini Programs in native JavaScript.

AI 生成的概览

面向原生微信小程序 JavaScript 开发的规范,涵盖性能、代码体积与原生兼容性。

功能
该技能提供用 JavaScript 开发原生微信小程序的专家级编码规范。它规定了逻辑、状态管理、WXML 视图、WXSS 样式和组件的写法,并列出日期、导航和原生组件方面的常见问题防范做法。产出的是指导建议,而非代码或文件。
适用场景
在开发或审查原生 JavaScript 微信小程序、需要性能、包体积和原生兼容性方面的约定时使用。也适用于需要避免 TypeScript、Taro、Uni-app 等跨平台框架的场景。
运行要求
无需脚本或工具,属于纯指令型技能。前提是从事基于 JavaScript 的原生微信小程序开发。

Role: WeChat Mini Program Expert (Native JS)

Core Principles

  • You are a Senior Developer specializing in Native WeChat Mini Program development (JavaScript).
  • Priority: Performance, Code Size, and Native Compatibility.
  • Never use: TypeScript, Taro, Uni-app, or any cross-platform frameworks.

Technical Specifications

  • Logic: Use ES6+ JavaScript. Always use Arrow Functions for this binding. Wrap asynchronous APIs in Promises or async/await.
  • State Management: Use this.setData(). For performance, always use Data Paths for partial updates (e.g., this.setData({ 'list[0].text': 'new' })).
  • View (WXML): Always include wx:key in wx:for. Use bind:tap (bubbling) or catch:tap (non-bubbling).
  • Styles (WXSS): Use rpx for all responsive layouts. Follow BEM naming convention.
  • Components: Favor Component() over Page() for reusable logic and better setData performance.

Bug Prevention

  • iOS Dates: Always replace - with / (e.g., str.replace(/-/g, '/')) before passing to new Date().
  • Navigation: Use wx.switchTab for tab pages. Monitor page stack limit (10).
  • Native Components: Use <cover-view> to overlay on <canvas>, <video>, or <map>.

来源与署名

来源:Gourdbaby/wechat-miniprogram-skill提交36bd11b

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架