[前端][vue]移动前端框架 M8 页面跳转相关

在使用移动前端框架 M8 页面跳转的过程中,容易混淆的部分特此说明:

由于移动前端框架 M8 使用 vue 技术栈,建议使用 vue-router 进行路由跳转:

使用 vue-router 跳转有两种方式,EJSAPI 调用与 vuerouter 调用

ejs 调用

ejs.page.open({
    pageUrl: './helloworld',
    data: {
        key1: 'value1'
    },
    // 是否使用vue-router跳转
    useRouter: true,
    success: function (result) {},
    error: function (error) {}
});

vue-routerAPI 调用

// 字符串
this.$router.push('helloworld');

// 对象
this.$router.push({ path: 'helloworld' });

// 带查询参数,变成 /helloworld?key1=value1
this.$router.push({ path: 'helloworld', query: { key1: 'value1' } });

ejs.page.open中的参数useRoutertrue时,使用vue-router单页面跳转,pageUrl仅需要填写相对的路由地址。例如 pageUrl: './helloworld'

如果使用useRouterfalse,调用时将在 EJS 容器内使用原生webview新打开页面。此时的pageUrl需要填写 dist 目录下的完整路径。例如 pageUrl: './index.html#/module/helloworld'

注意:

当页面资源部署在后台接口工程下时,访问不带·的页面地址,默认会被框架 sso 授权认证拦截。如果不需要 sso 授权认证(非第三方授权场景,例如企业微信、钉钉等),需要将.html部分带上,访问完整页面地址和跳转路径。例如:

http://127.0.0.1/frame/H5/dist/index.html#/module/helloworld

最后更新时间::
贡献者: 吴松泽