Share E-Book

微信小程序开发实战 (肖睿,何源)(Z-Library)

Author 肖睿, 何源

Mobile
Language Chinese

微信小程序以一种极度轻量化、无处不在、用完即走的方式全面连接了用户与服务,在给用户带来更好体验的同时,大幅降低了自身开发的门槛和成本。本书不局限于原生微信小程序开发,还涉及微信生态技术圈中的WePY框架应用、微信小游戏开发、使用Cocos Creator开发小游戏等内容,是读者从微信小程序入门到实战开发的极佳读物。 本书实用性强、示例丰富、侧重实战、与新技术结合紧密,可作为刚接触或即将接触微信小程序的开发者的指导用书,也适合有微信小程序开发经验,但还需进一步提升自我能力的开发者使用。

Format EPUB
Size 6.4 MB
192
Views
0
Downloads
0.00
Total Donations

AI Guide

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

Full assistant
AI guide
# 微信小程序开发实战 — Reading Guide ## 【One-Line Pitch】 A hands-on, task-driven introduction to WeChat Mini Program development that takes you from account registration and project scaffolding through core components, data binding, and into the WePY framework and mini-game development with Cocos Creator — ideal for beginners and intermediate developers who want to build real, shippable mini programs. ## 【Book Arc】 - **Opening (~0%–9%)**: Why mini programs matter — a comparison with native apps and HTML5 apps, the history and ecosystem of WeChat Mini Programs (BaaS, third-party services, analytics tools, investors, media, app stores), and the opportunities they create for low-cost, scenario-based services. Includes practical setup: registering an account, choosing a subject type (personal vs. enterprise), and installing the WeChat Developer Tool. - **Early (~9%–19%)**: Getting oriented with the developer tool interface (menu bar, toolbar, simulator, editor, debugger) and the project structure — the six root items (pages, utils, app.js, app.json, app.wxss, project.config.json). Covers WXSS basics (rpx units, style import, global vs. local styles, selectors), and the role of each file type (.js, .json, .wxml, .wxss) in a page component. - **Early (~19%–28%)**: Deep dive into configuration and lifecycle. app.json global config (pages array, window, tabBar, networkTimeout, debug), page-level config overrides, the App() registration function with its lifecycle hooks (onLaunch, onShow, onHide, onError), the Page() function with its full lifecycle (onLoad, onReady, onShow, onHide, onUnload, plus event handlers like onPullDownRefresh and onShareAppMessage), and CommonJS-style module exports/imports. - **Early–Middle (~28%–38%)**: First complete project — the "祥云天气" (Xiangyun Weather) mini program. Builds up from data binding in WXML, through wx:for list rendering with wx:key, to wx:if/wx:elif/wx:else and hidden for conditional rendering. Practical guidance on when to use wx:if vs. hidden (toggle cost vs. initial render cost). - **Middle (~38%–47%)**: Component library tour — text (selectable, space, decode), rich-text (nodes as HTML string or node array for e-commerce product details), progress (percent, stroke-width, color, active states), and navigator with its six open-type jump modes (navigate, redirect, switchTab, navigateBack, and others), including passing parameters via URL query strings and retrieving them in onLoad. ## 【Key Takeaways】 - **Mini programs win on cost and reach** (Early): They solve the cross-platform problem without needing separate iOS/Android engineers, integrate identity verification, payment, and sharing natively, and are especially suited for low-frequency, service-heavy scenarios tied to offline traffic. This is the strategic "why" before any code. - **The project skeleton is small but opinionated** (Early): Six root items — pages, utils, app.js, app.json, app.wxss, project.config.json — define everything. project.config.json preserves your tool settings across machines; app.wxss holds global styles; app.json is the global config; app.js registers the app and holds global data. Understanding this layout early prevents confusion later. - **WXSS is CSS with mini-program twists** (Early): rpx is the responsive unit (750rpx = screen width), @import brings in external stylesheets, and page-level .wxss overrides app.wxss for the same selectors. Use class for static styles and style only for dynamic values to keep rendering fast. - **Lifecycle functions are the backbone of app and page behavior** (Early): App() has onLaunch/onShow/onHide/onError; Page() adds onLoad/onReady/onShow/onHide/onUnload plus event handlers like onPullDownRefresh, onReachBottom, onShareAppMessage, and onPageScroll. Knowing when each fires — and that App() is a singleton registered only in app.js — is essential for managing data flow and side effects. - **Data binding plus wx:for and wx:if covers most UI logic** (Early–Middle): The weather project shows the pattern: define data in Page(), bind with {{}}, iterate with wx:for (using wx:key for stable identity and reordering efficiency), and conditionally render with wx:if/elif/else. Choose hidden over wx:if for frequent toggles (lower toggle cost, higher initial render cost). - **Navigation is richer than an <a> tag** (Middle): The navigator component and wx.navigateTo/wx.redirectTo/wx.switchTab/wx.navigateBack cover different jump semantics — navigate preserves the current page and can carry query parameters (?key=value&key2=value2), while switchTab is for tabBar pages. Retrieve parameters in onLoad via the options argument. - **Rich-text and progress components solve real product needs** (Middle): rich-text renders HTML strings or node arrays from backend data (essential for e-commerce detail pages), and progress provides visual feedback during waits with configurable percent, stroke-width, color, and active animation. ## 【Reading Tips】 - **Skim the ecosystem and history sections (0%–9%)** if you're already convinced you want to build mini programs — the strategic context is useful but not code-critical. Do read the registration and developer tool installation steps carefully; they're prerequisites for everything else. - **Deep-read the project structure and configuration chapters (9%–28%)**: app.json and page configs are where many real-world bugs hide (e.g., pages array order determines the home page; page config overrides app.json window settings). The App()/Page() lifecycle tables are worth memorizing or bookmarking. - **Follow the 祥云天气 project end-to-end (28%–38%)** — it's the book's core hands-on exercise. Build it yourself, then extend it (add more cities, use real weather APIs) to solidify data binding, list rendering, and conditional rendering. - **Treat the component chapters (38%–47%) as a reference**: you don't need to memorize every property of text, rich-text, progress, or navigator. Skim the tables, then return when you need a specific behavior (e.g., selectable text, rich-text nodes, or a specific navigation mode). - **Watch for the "注意" and "经验" callouts** — they flag common pitfalls (e.g., don't call getApp() inside App() functions, don't reassign exports, use module.exports instead) that will save you debugging time. ## 【Coverage Limits】 This guide covers the book's opening through the component and navigation chapters (~0–47%). The excerpts do not cover the later sections on WePY framework application, WeChat mini-game development, or Cocos Creator — those topics are mentioned in the blurb but not detailed in the sampled material. ##

Passage locations

Excerpt 1
务。 课工场在线 感谢您阅读本丛书,希望本丛书能成为您踏上全栈开发之旅的好伙伴! “Web全栈工程师系列”丛书编委会 未知 关于引用作品的版权声明 为了方便读者学习,促进知识传播,本书选用一些知名网站的相关内容作为学习案例。为了尊重这些内容所有者的权利,特此声明,凡本书中涉及的版权、著作权、商标权等权益,均属于原...
View in text
Excerpt 2
.js、.json、.wxml、.wxss。 (1)js文件是组件的脚本文件,定义了组件的数据和函数,是组件的灵魂部分。 (2)根目录的app.json是对微信小程序的全局配置。每个组件下的.json文件则是对这个组件的配置。 (3)微信使用WXML(WeiXin Markup Language)构建页面,类似于...
View in text
Excerpt 3
</text> <view class='week-list'> <view class='week'>{{weeks.week}}</view> <view class='temp'>{{weeks.temp.highest}}~{{weeks.temp.lowest}}C</view> </view> </v...
View in text
Excerpt 4
时间,缓解等待焦虑,提高用户的体验度。微信小程序progress组件提供了丰富的属性,使其能够适应各种不同的场景。表3.4展示了进度条组件progress的属性。 表3.4 进度条组件progress的属性 进度条组件progress的使用方式如示例3-4所示。 示例3-4: <view class="conta...
View in text

Recommended for You

Loading recommended books...
Failed to load, please try again later

Tip the Site

Scan the WeChat Pay or Alipay code to tip. No login required.

WeChat Pay
Alipay
Back to List