iOS路由以及URL介绍

2023-11-03  本文已影响0人  萧修

URL是统一资源定位符,由几部分组成

scheme://host:port/path/?parameter=xxx#anchor

https://www.baidu.com/Public/linux/?fr=aladdin#23

URL新增

在苹果api中,URL属性

其中host的获取有所更新,在iOS16增加新的是否编码

public var host: String? { get }

@available(macOS 13.0, iOS 16.0, tvOS 16.0, watchOS 9.0, *)
public func host(percentEncoded: Bool = true) -> String?
    

percentEncoded百分号编码

路由工具

本文引荐自己写的一个路由工具,方便多个项目引用,而不需要单独手写

需要配置索引
source 'https://gitee.com/gtools/mxs.git'
gitee下载

1、注册路由表
在Xcode中创建plist文件,配置app的scheme名字

Router.share.scheme = "app名称"
Router.initPages("RouterList.plist")

2、路由跳转:

web?url=https://www.baidu.com

open?page=test2&Id=1&name=ggx
上一篇 下一篇

猜你喜欢

热点阅读