3 迁移 app.js、app.json
小程序代码配置微信应用的配置
app.json
{
"pages":[
"pages/index1",
"pages/index2",
"pages/index3",
"pages/index4",
],
"window":{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "WeChat",
"navigationBarTextStyle":"black"
}
}
3.1.0 迁移 app.json ———— 路由pages配置
以上小程序 app.json
中 pages
字段 -> src/router.config.json
中 path
字段
{
"mode": "history",
"domain": "https://www.chameleon.com",
"routes":[
{
"url": "/cml/h5/index",
"path": "/pages/index1/index1",
"name": "首页",
"mock": "index.php"
},
{
"url": "/cml/h5/inner-detail",
"path": "/pages/index2/index2",
"name": "首页",
"mock": "index.php"
},
{
"url": "/cml/h5/inner-home",
"path": "/pages/index3/index3",
"name": "首页",
"mock": "index.php"
},
{
"url": "/cml/h5/inner-my",
"path": "/pages/index4/index4",
"name": "首页",
"mock": "index.php"
}
]
}
3.1.1 迁移 app.json ———— 其他配置
小程序 app.json
中 其他字段 -> src/app/app.cml
中配置
<script cml-type="json">
{
"wx": {
"window": {
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "Chameleon",
"navigationBarTextStyle":"black"
}
}
}
</script>
3.2 迁移 app.js ———— 生命周期映射
小程序 app.js
中的生命周期 -> src/app/app.cml
小程序 | chameleon |
---|---|
onLaunch | beforeCreate |
onShow | mounted |
onHide | destroyed |
总结
小程序中app.json app.js app.wxss
和 src/app/app.cml
的对应关系如下
小程序 app.js | cml项目 src/app/app.cml |
---|---|
app.js | <script></script> |
app.wxss | <style></style> |
app.json | <script cml-type="json"></script> |