1***@qq.com
1***@qq.com
  • 发布:2021-11-05 17:35
  • 更新:2021-12-06 17:36
  • 阅读:1013

vue setup里怎么接收上一个页面传过来的参数呢

分类:uni-app

vue setup里怎么接收上一个页面传过来的参数呢

2021-11-05 17:35 负责人:无 分享
已邀请:
[已删除]

[已删除]

  /**  
   * 获取页面传递过来的参数  
   */  
  static getPathQueries<T extends object, K extends keyof T = keyof T>(): T {  
    const pages = getCurrentPages()  
    const page = pages[pages.length - 1]  

    let fullPaths: string = (page as any).$page.fullPath.split('?')  
    let query = decodeURIComponent(fullPaths[1])  
    let queries = query.split('&')  
    let result = {} as T  

    for (let index = 0; index < queries.length; index++) {  
      const element = queries[index]  
      if (element) {  
        const elements = element.split('=')  

        if (elements && elements.length === 2) {  
          result[elements[0] as unknown as K] = elements[1] as unknown as T[K]  
        }  
      }  
    }  

    return result  
  }

该问题目前已经被锁定, 无法添加新回复