6***@qq.com
6***@qq.com
  • 发布:2022-01-26 23:13
  • 更新:2022-07-28 16:00
  • 阅读:1994

uniapp云打包成apk后 页面不跳转

分类:uni-app
<template>    
    <view>    
        <view class="u-page login-from">    
            <u--form labelPosition="top" labelWidth="auto" :model="formModel" :rules="rules" ref="uform">    
                <u-form-item label="用户名" prop="userName" borderBottom ref="item1">    
                    <u--input v-model="formModel.userName" border="none"></u--input>    
                </u-form-item>    
                <u-form-item label="密码" prop="password" borderBottom ref="item2">    
                    <u--input v-model="formModel.password" border="none" type="password"></u--input>    
                </u-form-item>    
                <button type="primary" shape="circle" @click="login">登录</button>    
                <br>    
                <button type="default" shape="circle" form-type="reset">注册</button>    
            </u--form>    
        </view>    
    </view>    
</template>    

<script>    
    import {    
        doLogin    
    } from '@/common/http/api.js';    
    export default {    
        data() {    
            return {    
                formModel: {    
                    userName: '',    
                    password: ''    
                },    
                rules: {    
                    'userName': [{    
                        type: 'string',    
                        required: true,    
                        message: '请填写用户名',    
                        trigger: ['blur', 'change']    
                    }],    
                    'password': [{    
                        type: 'string',    
                        required: true,    
                        message: '请填写用户密码',    
                        trigger: ['blur', 'change']    
                    }]    
                }    

            }    
        },    
        onReady() {    
            // 如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则    
            this.$refs.uform.setRules(this.rules)    
        },    

        /*      onLoad({userName,password}) {    
                    this.userName=userName    
                    this.password=password    
                }, */    

        methods: {    
            login() {    
                this.$refs.uform.validate().then(obj => {    
                    uni.$u.toast('校验通过')    
                    const params = {    
                        userCode: this.formModel.userName,    
                        userPwd: this.formModel.password    
                    }    
                    doLogin(params).then((res) => {    
                        console.log(res)    
                        uni.$u.vuex('vuex_token', res.token)    
                        uni.$u.vuex('vuex_user', res.loginUser)    
                        //uni.setStorageSync('token', res.token);    
                        // 登录成功提示    
                        uni.showToast({    
                            title: "登录成功"    
                        })    
                         setTimeout(() => {    
                            // 回源跳转    
                            const url = uni.getStorageSync("currentRoute") || "/pages/index/index"    
                            uni.$u.route({    
                                type: "reLaunch",    
                                url    
                            })     
                        }, 1500)     
                    })    

                }).catch(errors => {    
                    uni.$u.toast('校验失败')    
                })    
            },    
        }    
    }    
</script>    

<style lang="scss" scoped>    
    .login-from {    
        width: 600rpx;    
        margin: auto;    
        height: 200rpx;    
        left: 0;    
        top: 0;    
        bottom: 0;    
        right: 0;    
        position: absolute;    
    }    
</style>  

模拟器运行和真机运行都能跳转,就是打包成apk后不得行,登录成功是提示了的

2022-01-26 23:13 负责人:无 分享
已邀请:
南极潇湘

南极潇湘

看起来你是用的uView库做的是吗?
给你推荐几个方案:
1、直接换成uni.reLaunchl来跳转
2、更新uView库到最新版 试试问题是否已修复 我看了一下 https://github.com/umicro/uView
3、加他们官方群寻求帮助,你可能翻墙查看github不方便,我贴出来:
uView UI,是uni-app生态优秀的UI框架,全面的组件和便捷的工具会让您信手拈来,如鱼得水

官方文档:https://v1.uviewui.com
官方1群:1042987248(已满)
官方2群:249718512(已满)
官方3群:1129077272(已满)
官方4群:1084514613(已满)
官方5群:863820668(已满)
官方6群:745721078(已满)
官方7群:627867855(已满)
官方8群:496409492(已满)
官方9群:828504448(已满)
点击加10群交流反馈:232041042

  • 6***@qq.com (作者)

    谢谢 换成uni.reLaunch就可以了 但是之前用 uni.redirectTo试过,不清楚为什么也不得行

    2022-01-28 14:47

BoredApe

BoredApe - 有问题就会有答案。

请上传一个能重现问题的测试工程

1***@qq.com

1***@qq.com

请问解决了嘛?我也遇到相同问题了

3***@qq.com

3***@qq.com

请问解决了嘛?我也遇到相同问题了

  • 3***@qq.com

    我是打包后不止跳转 所有的功能 都出现了异常是怎么回事

    2022-07-28 16:24

要回复问题请先登录注册