Share E-Book
Scan to open this page

Scan with your phone to open this page

Author: 阿里云

No description

AI Reading Assistant

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

AI guide
# 小程序开发不求人 (阿里云) 【One-Line Pitch】 A practical, hands-on guide to building Alipay mini-programs from scratch — covering everything from account registration and IDE usage to core APIs, UI components, and real-world scenarios like QR-code ordering and photo upload. Ideal for beginners who want to ship a working mini-program without wading through scattered official docs. 【Book Arc】 - **Opening (~0%–7%)**: Why Alipay mini-programs matter — the platform's positioning, its 70% focus on offline commercial life services, and the "building-block" ecosystem where Alipay capabilities (payment, logistics, LBS) can be combined. Then walks through pre-development preparation: account registration and developer onboarding. - **Early (~7%–20%)**: Developer tool (IDE) mastery — the main interface layout, compile modes, cache clearing, real-device debugging, preview, and upload workflow. Introduces the mini-program file structure (app.json, app.js, app.acss) and the four-file page pattern (.json, .axml, .acss, .js). - **Early (~20%–33%)**: Global and page configuration deep-dive — window settings, tabBar configuration, ACSS styling rules (rpx units, selector restrictions, style imports), and the App() lifecycle with launch parameters and getApp() usage. - **Middle (~33%–47%)**: Page runtime mechanics — Page() registration, lifecycle callbacks (onLoad, onShow, onReady, onHide, onUnload), the events object, setData and $spliceData for data updates, and performance tips like $batchedUpdates. Includes the HTTPS networking chapter explaining my.request and domain whitelist requirements. - **Middle (~47%–60%)**: Practical scenario chapters — QR-code scanning for restaurant ordering (my.scanCode), image upload with my.uploadFile (including server-side Java code), and network status detection (my.getNetworkType). - **Late (~60%–end)**: UI component library (mini-ali-ui) — tips-dialog, modal, and input components with their properties, slots, and usage examples. Excerpts end here; later chapters on publishing and operations are not covered in this guide. 【Key Takeaways】 - **Alipay mini-programs are commerce-first** (Early): Unlike WeChat's game/live-streaming focus, 70% of Alipay's million-plus mini-programs serve offline commercial life services — the "closest to money" scenarios. This shapes the platform's API priorities (payment, scan, location). - **The IDE is your daily workspace** (Early): Master compile modes for testing specific pages with parameters, use auto-preview to avoid repeated QR scans, and understand that upload requires associating your local project with the backend mini-program first. - **Four files per page, one global trio** (Early): Every page needs .json (config), .axml (template), .acss (style), and .js (logic). The app-level trio — app.json (pages list, window, tabBar), app.js (App() registration, global data), app.acss (global styles) — defines the whole mini-program. - **ACSS is CSS plus rpx** (Early): ACSS is 100% CSS-compatible with additions. Use rpx (responsive pixel, 750rpx = screen width) for cross-device adaptation. Avoid .a-/.am- prefixed selectors (system-reserved) and attribute selectors (unsupported). Local resource references must use absolute paths. - **setData is the only way to update views** (Middle): Directly mutating this.data won't update the page and causes inconsistency. Use setData with data paths (e.g., 'a.b[2].message'), avoid setting undefined values, and batch multiple setData calls inside this.$batchedUpdates for performance. - **HTTPS is mandatory for production** (Middle): my.request only works with whitelisted domains in production. During development you can ignore domain checks in the IDE, but the whitelist must be configured before launch. Default content-type is application/json, not form-urlencoded. - **QR codes replace tedious input** (Middle): my.scanCode lets users scan QR codes to pass data (e.g., table numbers for restaurant ordering). This pattern extends to product barcodes, shared bikes, and any scenario where encoding information beats manual entry. - **Domain whitelist gates all network APIs** (Middle): my.request, my.uploadFile, my.downloadFile, and my.connectSocket all require the server domain to be pre-configured in the mini-program admin console — configure this early to avoid debugging surprises. 【Reading Tips】 - **Skim the opening chapters** (~0%–7%) if you already know why you want to build a mini-program; the platform background is motivational but not actionable. - **Deep-read the IDE chapter** (~7%–13%) — compile modes and upload workflow are common stumbling blocks for beginners; getting these right saves hours. - **Study the app.json and page configuration sections carefully** (~13%–33%) — tabBar, window settings, and ACSS rules are foundational; the rpx unit explanation is essential for responsive layouts. - **Pay special attention to the setData and $spliceData examples** (~40%–47%) — data binding is where most bugs originate; the immutable-data pattern shown here prevents subtle state issues. - **The scenario chapters** (~47%–60%) are best read as templates — the QR-scan and upload examples give you copy-paste starting points for common business needs. The Java server code for file download is useful if you control your backend. 【Coverage Limits】 This guide covers the first roughly two-thirds of the book (through UI components). Excerpts do not cover later chapters on publishing, review, operations, marketing tools, or the Alipay ecosystem's center-channel traffic policies — consult the full book for those.
Page 18
功能。本文档从左至右介绍各项功能。 小程序 15 编译模式 在普通编译模式下,小程序初始的启动页面是 app.json 文件 pages 列表的首 个页面,且不带任何参数。 如需快速调试其他页面 或 设置参数: 1. 在此项下拉列表中点击 + 添加编译模式。 2. 在弹窗中填写 模式名称、页面参数、全局参数,选择...
View in text
Excerpt 2
lobalData++; // b.js // 定义页面局部变量 localValue,只在 b.js 有效 var localValue = 'b'; // 如果 a.js 先运行,globalData 会返回 2 console.log(getApp().globalData); a.js 和 b.js 两个...
View in text
Excerpt 3
tleClick(){ // 点击标题触发 onTabItemTap(e){ // e.from 是点击且切换 tabItem 后触发,值是“user”表示用户点击触发的事件; 值是“api”表示 switchTab 触发的事件 console.log('触发 tab 变化的类型', e.from) consol...
View in text
Excerpt 4
端通过这个 key 可以获取到 文件二进制内容。 文件类型支持图片、视频、音频 fileType String 是 ( image / video / audio) 75 属性 类型 必填 描述 success Function 否 调用成功的回调函数。 fail Function 否 调用失败的回调函数。 调用...
View in text
Excerpt 5
</button> </view> 90 <view class="form-row-content"> <input class="input" type="number" placeholder="数字输入框" /> </view> </view> <view class="form-line" /> <vi...
View in text
Excerpt 6
为开发者提供了小程序二维码 DEMO,开发者可以参考 快速示 例 文档进行体验和实现快速接入。 111 Object: { mobile } disabled 手机号是否可以编辑 Boolen false 验证码输入时事件 onCodeInput EventHandle onCodeInput(e) classN...
View in text
Excerpt 7
135 模板开发主要有四步: 1、系统服务商( ISV) 需创建和开发第三方应用。如已经拥有,则可以沿用; 2、在第三方应用下创建小程序模板,并完成开发; 3、引导商户完成小程序授权: 系统服务商(ISV)通过第三方应用,引导商户将小程序应用授权给自己,以便进行后面模 板小程序实例化的实施操作; 系统服务商(IS...
View in text
Tags
AI categories
ProgrammingMobileWeb Technology
Publisher: iBooker it-ebooks
Publish Year: 2021
Language: English
File Format: PDF
File Size: 2.0 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…