• vue 如何点击按钮返回上一页


    1,vue 如何点击按钮返回上一页呢?

         这是vue挂载的范围html代码

          <div @click="goOff()">返回</div>

         下面是点击返回的方法

          第一种只返回上一页

               goOff(){
                    this.$router.go(-1);
                },

          第二种 返回上一页,如果没有上一页返回首页

        methods: {
            back(){
                if (window.history.length <= 1) {
                    this.$router.push({path:'/'})
                    return false
                } else {
                    this.$router.go(-1)
                }
            }
        },

    2,下面介绍一点vue调取接口小知识

               actAllProfit(){                //调取接口的函数
                    var params = {};                //这是调取接口时的请求参数 明白点就是我们要传过去的参数
                    var reqUrl = this.diviBaseUrl + '/bonuses/grossProfit';               //这是后台接口地址
                    this.$http.get(reqUrl,{               //get方式发送请求
                        params: params           //把外面声明的参数传过去
                    }).then((res)=>{   //巧妙运用箭头函数
                        if(!res){return;}
                        this.allProfit = res.Profit; //res就是后台返回的所有数据 前端需要接收并保存
                    })
                }

  • 相关阅读:
    linux tcp中time_wait
    linux查看系统信息
    运行程序出错无法找到库文件
    安装keepalived
    python 深拷贝与浅拷贝
    python import eventlet包时提示ImportError: cannot import name eventlet
    [原创] 用两个queue实现stack的功能
    [原创] 用两个stack实现queue的功能
    [原创] 编写函数,实现对链表元素的排序与分类
    python 装饰器
  • 原文地址:https://www.cnblogs.com/lgnblog/p/9957661.html
Copyright © 2020-2023  润新知