Uniapp Native Page Guide

In Uniapp, you can use the uni.navigateToNative method to open a native page. The specific steps are as follows:

  1. Configure the paths and parameters of native pages in the pages.json file of a Uniapp project.
{
  "pages": [
    // 其他页面配置
    {
      "path": "pages/nativePage",
      "style": {
        "app-plus": {
          "titleNView": {
            "titleText": "原生页面"
          }
        }
      }
    }
  ]
}
  1. Call the uni.navigateToNative method where you need to invoke the native page.
uni.navigateToNative({
  url: 'pages/nativePage',
  params: {
    // 传递给原生页面的参数
  },
  success: (res) => {
    console.log(res)
  },
  fail: (err) => {
    console.error(err)
  }
})
  1. Receive and handle parameters on the native page.
Intent intent = getActivity().getIntent();
String param1 = intent.getStringExtra("param1");
String param2 = intent.getStringExtra("param2");
// 处理参数

By following the steps above, you can successfully invoke a native page in Uniapp and pass parameters. It is important to note that the functionality of invoking native pages can only be used on the app side, not on the H5 side.

bannerAds