


Let's take a look at the differences between Alipay mini program and WeChat mini program development
Apr 14, 2021 am 10:23 AMA brief discussion on the difference between the development of Alipay mini programs and WeChat mini programs
1. app.json
(1) Set the status bar, navigation bar, title, and window background color common to the mini program
Alipay mini program
"window": { "defaultTitle": "病案到家", //頁面標(biāo)題 "titleBarColor": "#1688FB" //導(dǎo)航欄背景色 },
WeChat Mini Program
"window": { "backgroundTextStyle": "light",//窗口的背景色 "navigationBarBackgroundColor": "#1688FB",//導(dǎo)航欄背景顏色 "navigationBarTitleText": "病案到家",//導(dǎo)航欄標(biāo)題文字內(nèi)容 "navigationBarTextStyle": "white"//導(dǎo)航欄標(biāo)題顏色,僅支持 black/white },
Related learning recommendations: 小programDevelopmentTutorial
(2) Set tabBar
Alipay Mini Program
"tabBar": { "textColor": "#333333",//默認顏色 "selectedColor": "#1688FB",//選中顏色 "backgroundColor": "#ffffff",//背景色 "items": [ { "icon": "/images/indexGrey.png", "activeIcon": "/images/indexWhite.png", "pagePath": "pages/homeIndex/homeIndex", "name": "首頁" }, { "icon": "/images/personGrey.png", "activeIcon": "/images/personWhite.png", "pagePath": "pages/orderList/orderList", "name": "我的" } ] }
WeChat Mini Program
"tabBar": { "color": "#333333", "selectedColor": "#1688FB", "backgroundColor": "#ffffff", "borderStyle": "#e5e5e5", "list": [ { "iconPath": "/images/indexGrey.png", "selectedIconPath": "/images/indexWhite.png", "pagePath": "pages/homeIndex/homeIndex", "text": "首頁" }, { "iconPath": "/images/personGrey.png", "selectedIconPath": "/images/personWhite.png", "pagePath": "pages/orderList/orderList", "text": "我的" } ] }
2. Pages
(1) File naming is different
Alipay Mini Program
##WeChat Mini Program
I created pages in the WeChat mini program and the Alipay mini program respectively. The difference is:
1. In the Alipay mini program The suffix of the view layer page file is "axml", and the suffix of the style file is "acss"; 2. The suffix of the view layer page file in the WeChat applet is "wxml", and the suffix of the style file is "wxss". (2) View layer page axml and wxml1. Bubble events and non-bubble eventsAlipay applet
onTap, catchTapOn event binding will not prevent bubbling events from bubbling upwards, while catch event binding can prevent bubbling events from bubbling upwards.<button class="weui-btn" onTap="login" type="primary">登錄</button>
WeChat Mini Program
bindtap、
catchtouchstart
bindEvent binding will not prevent bubbling events from bubbling upwards.
catchEvent binding can prevent bubbling events from bubbling upwards.
<button class="weui-btn" bindtap='login' type="primary">登錄</button>2. List rendering
Page({ data: { list: [{ Title: '支付寶', }, { Title: '微信', }] } })
Alipay applet
<block a:for="{{list}}"> <view key="item-{{index}}" index="{{index}}">{{item.Title}}</view> </block>
WeChat applet
<block wx:for="{{list}}"> <view wx:key="this" wx:for-item="item">{{item.Title}}</view> </block>3. Conditional rendering
Alipay applet
<view a:if="{{length > 5}}"> 1 </view> <view a:elif="{{length > 2}}"> 2 </view> <view a:else> 3 </view>
WeChat Mini Program
<view wx:if="{{length > 5}}"> 1 </view> <view wx:elif="{{length > 2}}"> 2 </view> <view wx:else> 3 </view>
3.Different usage of components in the two mini programs commonly used in the development process
(1) Interaction1. Message prompt boxAlipay applet
my.showToast({ type: 'success',//默認 none,支持 success / fail / exception / none’。 content: '操作成功',//文字內(nèi)容 duration: 3000,//顯示時長,單位為 ms,默認 2000 success: () => { my.alert({ title: 'toast 消失了', }); }, });
my.hideToast()//隱藏弱提示。
WeChat Mini Program
wx.showToast({ title: '成功',//提示的內(nèi)容 icon: 'success',//success 顯示成功圖標(biāo);loading 顯示加載圖標(biāo);none不顯示圖標(biāo) duration: 2000 }) //icon為“success”“l(fā)oading”時 title 文本最多顯示 7 個漢字長度rrree2. Message prompt box
Alipay Mini Program
wx.hideToast() //隱藏
my.showLoading({ content: '加載中...', delay: 1000, });
WeChat Mini Program
my.hideLoading();
wx.showLoading({ title: '加載中', })3.http request
Alipay Mini Program
wx.hideLoading()
WeChat Mini Program
my.httpRequest({ url: 'http://httpbin.org/post', method: 'POST', data: { from: '支付寶', production: 'AlipayJSAPI', }, headers:"",//默認 {'Content-Type': 'application/x-www-form-urlencoded'} dataType: 'json', success: function(res) { my.alert({content: 'success'}); }, fail: function(res) { my.alert({content: 'fail'}); }, complete: function(res) { my.hideLoading(); my.alert({content: 'complete'}); } });
In fact, the API methods provided by WeChat Mini Program and Alipay Mini Program are roughly the same The same, except that the WeChat applet starts with "wx." and the Alipay applet starts with "my.". The rest may be just that the fields "text, content, name, title" in the API method are named differently.
(2) Selector1. Time selectorAlipay applet
The Alipay applet provides an API, my.datePicker(object)wx.request({ url: 'test.php', //僅為示例,并非真實的接口地址 data: { x: '', y: '' }, header: { 'content-type': 'application/json' // 默認值 }, success (res) { console.log(res.data) } })
WeChat applet
WeChat applet It is implemented through the picker componentmy.datePicker({ format: 'yyyy-MM-dd',//返回的日期格式, currentDate: '2012-12-12',//初始選擇的日期時間,默認當(dāng)前時間 startDate: '2012-12-10',//最小日期時間 endDate: '2012-12-15',//最大日期時間 success: (res) => { my.alert({ content: res.date, }); }, });
<view class="section"> <view class="section__title">日期選擇器</view> <picker mode="date" value="{{date}}" start="2015-09-01" end="2017-09-01" bindchange="bindDateChange"> <view class="picker"> 當(dāng)前選擇: {{date}} </view> </picker> </view2. Province and city selector
Alipay applet
Alipay applet The program provides an API, my.multiLevelSelect(Object)The cascade selection function is mainly used for multi-level associated data selection, such as province and city information selection. 1.1. Introduce a json format file of a province or city http://blog.shzhaoqi.com/uploads/js/city_json.zip1.2. Introduce this file in js1.3. Use my.multiLevelSelect(Object)Page({ data: { date: '2016-09-01', }, bindDateChange: function(e) { console.log('picker發(fā)送選擇改變,攜帶值為', e.detail.value) this.setData({ date: e.detail.value }) }, })
WeChat Mini Program
WeChat Mini Program still uses the picker component Implementedvar citysJSON = require('../../utils/city.js'); Page({ data: { provinces: '陜西省', city: '西安市', area: '碑林區(qū)' }, chooseAddress: function () { my.multiLevelSelect({ title: '選擇省市區(qū)',//級聯(lián)選擇標(biāo)題 list: citysJSON.citys, success: (res) => { this.setData({ provinces: res.result[0].name, city: res.result[1].name, area: res.result[2].name, }) } }); }, })
<view class="section"> <view class="section__title">省市區(qū)選擇器</view> <picker mode="region" bindchange="bindRegionChange" value="{{region}}" custom-item="{{customItem}}"> <view class="picker"> 當(dāng)前選擇:{{region[0]}},{{region[1]}},{{region[2]}} </view> </picker> </view> //custom-item 可為每一列的頂部添加一個自定義的項,可為空(3) Mini program evokes payment
Alipay mini program
Page({ data: { region: ['廣東省', '廣州市', '海珠區(qū)'], customItem: '全部' }, bindRegionChange: function (e) { console.log('picker發(fā)送選擇改變,攜帶值為', e.detail.value) this.setData({ region: e.detail.value }) } })
WeChat Mini Program
my.tradePay({ tradeNO: '201711152100110410533667792', // 調(diào)用統(tǒng)一收單交易創(chuàng)建接口(alipay.trade.create),獲得返回字段支付寶交易號trade_no success: (res) => { my.alert({ content: JSON.stringify(res), }); }, fail: (res) => { my.alert({ content: JSON.stringify(res), }); } });(4) Phone
支付寶小程序
my.makePhoneCall({ number: '400-8097-114' })
微信小程序
wx.makePhoneCall({ phoneNumber: '400-8097-114' })
(5)獲取登錄憑證(code)
支付寶小程序
my.getAuthCode({ success (res) { if (res.authCode) { console.log(res.authCode) } } })
微信小程序
wx.login({ success (res) { if (res.code) { console.log(res.code) } } })
支付寶小程序與微信小程序有很多相似之處,不論是組件還是api都會給你熟悉的感覺!
相關(guān)免費學(xué)習(xí)推薦:微信小程序開發(fā)
The above is the detailed content of Let's take a look at the differences between Alipay mini program and WeChat mini program development. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)