1. watch: {
    2. $route: {
    3. //$route发生变化时执行下面的函数
    4. handler: function (to) {
    5. console.log(to, 'to')
    6. if (to.query.auth_code) {
    7. this.getStaffInfo(to.query.auth_code)
    8. }
    9. const query = to.query
    10. console.log(query, 'query')
    11. if (query) {
    12. this.redirect = query.redirect
    13. this.otherQuery = this.getOtherQuery(query)
    14. console.log(this.redirect, 'redirect')
    15. console.log(this.otherQuery, 'otherQuery')
    16. }
    17. },
    18. immediate: true//是否在初始化时就监听变化
    19. }