目前支持 wxml、wxs、js/ts、json,less/sass 等文件类型,资源支持通过配置区分不同平台
wxml中使用
html
<!-- #if MP -->
<view class="test-view">wechat</view>
<!-- #elif IOS -->
<view class="test-view">iOS</view>
<!-- #elif ANDROID -->
<view class="test-view">android</view>
<!-- #endif -->
wxss
css
.test-view{
/* #if MP */
color: red;
/* #elif IOS */
color: green;
/* #elif ANDROID */
color: yellow;
/* #endif */
}
js中微信小程序登录:
javascript
// #if MP
wx.login({})
// #elif IOS
wx.getMiniProgramCode({})
// #elif ANDROID
wx.getMiniProgramCode({})
// #endif
JSON
javascript
{
"window": {
"navigationBarTitleText": "Weixin",
},
"mini-wechat": {
"window": {
"navigationBarTitleText": "wechat demo"
}
},
"mini-ios": {
"window": {
"navigationBarTitleText": "iOS demo"
}
},
"mini-android": {
"window": {
"navigationBarTitleText": "android demo"
}
}
}