JS
Wechat Mini Program Development
What is Wechat Mini Program?
Wechat Mini Program is a small application that runs within Wechat. It is a way to deliver a rich user experience without the need to install an app. It is a great way to reach a large audience without the need to go through the app store.
Download IDE
To develop Wechat Mini Program, you need to download the Wechat Mini Program IDE. You can download it from the Wechat Mini Program IDE website.
Create a New Project
app.json
Reference URL
{
"pages": [
"pages/index/index"
],
"window": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "Weixin",
"navigationBarBackgroundColor": "#ffffff"
},
"style": "v2",
"componentFramework": "glass-easel",
"sitemapLocation": "sitemap.json",
"lazyCodeLoading": "requiredComponents",
"useExtendedLib": {
"weui": true
}
}
WeUI
Recommended Method
Since WeChat basic library version is above 2.2.1, you can use useExtendedLib to enable WeUI.
- Add
useExtendedLib
toapp.json
to use WeUI.
{
"useExtendedLib": {
"weui": true
}
}
- Where you want to use WeUI, import the WeUI component.
{
"usingComponents": {
"mp-badge": "weui-miniprogram/badge/badge"
}
}
- Use the WeUI component in the page.
<mp-badge content="123"></mp-badge>
模版消息
客户端授权
wx.requestSubscribeMessage({
tmplIds: ['订阅消息ID','可以多写几个'],
success(res) {
console.log(res)
}
})