请选择 进入手机版 | 继续访问电脑版
帖子
帖子
用户
博客
课程
12下一页
返回列表 发新帖
显示全部楼层
28
帖子
0
勋章
228
Y币

[多端开发] 以下代码不会跳转到主页,是什么问题呢

[复制链接]
发表于 2022-6-29 08:22:59
            //跳转系统主页
            goIndex() {
                var param = {
                    "name": "root",
                    "tabBar": {
                        "frames": [{
                            "title": "首页",
                            "name": "home",
                            "url": "../tab-chat/tab-chat.stml"
                        }, {
                            "title": "课程",
                            "name": "course",
                            "url": "../tab-course/tab-course.stml"
                        }, {
                            "title": "发现",
                            "name": "discover",
                            "url": "../tab-discover/tab-discover.stml"
                        }, {
                            "title": "我的",
                            "name": "user",
                            "url": "../tab-user/tab-user.stml"
                        }],
                        "list": [{
                            "text": "首页",
                            "iconPath": "../image/home00.png",
                            "selectedIconPath": "../image/home01.png"
                        }, {
                            "text": "课程",
                            "iconPath": "../image/course00.png",
                            "selectedIconPath": "../image/course01.png"
                        }, {
                            "text": "发现",
                            "iconPath": "../image/discover00.png",
                            "selectedIconPath": "../image/discover01.png"
                        }, {
                            "text": "我的",
                            "iconPath": "../image/user00.png",
                            "selectedIconPath": "../image/user01.png"
                        }],
                        "textOffset": 6,
                        "color": "#999999",
                        "selectedColor": "#333333",
                        "scrollEnabled": false
                    }
                };
                api.openTabLayout(param);
            },

380
帖子
4
勋章
6
Y币
关闭上层页面就可以回到主页
28
帖子
0
勋章
228
Y币
没明白什么意思,上层页面是指 reload.stml 文件吗?我写的这个 goIndex 函数写在了 reload.stml 文件的 method 里面,而我定义了
<content src="./pages/reload/reload.stml" />
技术咨询-F · 2022-6-29 10:03关闭上层页面就可以回到主页
380
帖子
4
勋章
6
Y币
"name": "tab",  改个name 试试。


意思就是:

页面openWin1->openWin2, closeWin2 就是回到win1
rjblwhp · 2022-6-29 10:58没明白什么意思,上层页面是指 reload.stml 文件吗?我写的这个 goIndex 函数写在了 reload.stml 文件的 method 里面,而我定义了
28
帖子
0
勋章
228
Y币
页面openWin1->openWin2, closeWin2 就是回到win1

-- 好像不是这种情况

"name": "tab",  改个name 试试。
--改name行不通
技术咨询-F · 2022-6-29 11:05"name": "tab",  改个name 试试。


380
帖子
4
勋章
6
Y币
那有可能是页面路径传的不对

   "url": "../tab-chat/tab-chat.stml"
rjblwhp · 2022-6-29 13:26页面openWin1->openWin2, closeWin2 就是回到win1

-- 好像不是这种情况
28
帖子
0
勋章
228
Y币
<template name="reload">

  <view>
     <img src="../../image/home00.png"  onclick="goIndex()" />
     <img src="../../image/home01.png"  onclick="goIndex()" />
  </view>

</template>

<script>
    export default {
        name: "reload",
        apiready() { //like created
            this.goIndex()
        },
        data() {
            return {

            };
        },

        methods: {

            //跳转系统主页
            goIndex() {
                var param = {
                    "name": "root",
                    "tabBar": {
                        "frames": [{
                            "title": "首页",
                            "name": "tab-chat",
                            "url": "../tab-chat/tab-chat.stml"
                        }, {
                            "title": "课程",
                            "name": "course",
                            "url": "../tab-course/tab-course.stml"
                        }, {
                            "title": "发现",
                            "name": "discover",
                            "url": "../tab-discover/tab-discover.stml"
                        }, {
                            "title": "我的",
                            "name": "user",
                            "url": "../tab-user/tab-user.stml"
                        }],
                        "list": [{
                            "text": "首页",
                            "iconPath": "../../image/home00.png",
                            "selectedIconPath": "../../image/home01.png"
                        }, {
                            "text": "课程",
                            "iconPath": "../../image/course00.png",
                            "selectedIconPath": "../../image/course01.png"
                        }, {
                            "text": "发现",
                            "iconPath": "../../image/discover00.png",
                            "selectedIconPath": "../../image/discover01.png"
                        }, {
                            "text": "我的",
                            "iconPath": "../../image/user00.png",
                            "selectedIconPath": "../../image/user01.png"
                        }],
                        "textOffset": 6,
                        "color": "#999999",
                        "selectedColor": "#333333",
                        "scrollEnabled": false
                    }
                };
                api.openTabLayout(param);
            }
        }
    }
</script>

<style>

</style>这个是 reload.stml 文件我已经验证过, 路径是对的,请帮帮看看是哪里的问题。登录进去没有跳转到主页。


技术咨询-F · 2022-6-29 17:20那有可能是页面路径传的不对

   "url": "../tab-chat/tab-chat.stml"
380
帖子
4
勋章
6
Y币
加console.log, 看代码执行到哪了

  goIndex() {

  console.log(1234)  // 看执行到这没
rjblwhp · 2022-6-29 17:41export default {
        name: "reload",
        apiready() { //like created
28
帖子
0
勋章
228
Y币
本帖最后由 rjblwhp 于 2022-6-29 21:08 编辑

我在 api.openTabLayout(param); 语句前面 console.log(5678) 是有输出的,在语句 api.openTabLayout(param); 之后 console.log(9999) 也是有输出的。
技术咨询-F · 2022-6-29 19:51加console.log, 看代码执行到哪了

  goIndex() {

28
帖子
0
勋章
228
Y币
name 从 root 改为其它就可以了。我当时理解错你的意思了。
rjblwhp · 2022-6-29 13:26页面openWin1->openWin2, closeWin2 就是回到win1

-- 好像不是这种情况
12下一页
您需要登录后才可以回帖 登录

本版积分规则