Skip to content
This repository has been archived by the owner on Nov 17, 2022. It is now read-only.

[RFC] 小程序的应用及页面配置如何编写? #558

Open
ChrisCindy opened this issue Sep 23, 2022 · 1 comment
Open

[RFC] 小程序的应用及页面配置如何编写? #558

ChrisCindy opened this issue Sep 23, 2022 · 1 comment

Comments

@ChrisCindy
Copy link
Contributor

ChrisCindy commented Sep 23, 2022

Rax 怎么做?

应用配置

放置于 src/app.json 中,示例如下:

{
  "routes": [
    {
      "path": "/",
      "source": "pages/Home/index",
      "window": {
        "barButtonTheme": "default"
      }
    },
    {
      "path": "/about",
      "source": "pages/About/index",
      "window": {
        "barButtonTheme": "light"
      }
    }
  ],
  "window": {
    "title": "Rax App 1.0",
  }
}

页面配置

放置于 src/app.json 中的 routes 数组的 window 字段中,示例同上


Taro 怎么做?

应用配置

放置于 src/app.config.js 中

页面配置

放置于页面 js 同级目录下的同名 config.js 文件中


ICE 怎么做?

应用配置

src/app.ts 中导出 miniappManifest 变量:

export const miniappManifest = {
  title: 'miniapp test',
  routes: [
    'index',
    'about',
    'second/profile',
  ],
};

此处需要注入环境变量(如 process.env.PLATFROM)以支持多小程序端差异化逻辑编写

页面配置

各页面 ts 文件中通过 getConfig 方法导出,同样需要实现区分端的环境变量

@ChrisCindy
Copy link
Contributor Author

// 应用
export const miniappManifest = defineMiniappManifest((platform) => {
return {
title: 'miniapp test',
routes: [
'index',
'about',
'second/profile',
],
};
})


// 页面
export function getConfig(data, context) {
return { }
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant