Skip to content

Commit c4e9abd

Browse files
authored
Update README.md
1 parent 756d76a commit c4e9abd

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

README.md

+46
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,52 @@
99
![CocoaPods](https://img.shields.io/badge/CocoaPods-supported-brightgreen.svg)
1010
[![License](http://img.shields.io/badge/license-MIT-lightgrey.svg?style=flat)](http://mit-license.org)
1111

12+
13+
14+
## 迁移至[Khala](https://github.com/linhay/Khala)
15+
16+
1. ##### 安装[Khala](https://github.com/linhay/Khala)
17+
18+
```
19+
pod 'Khala'
20+
```
21+
22+
2. ##### 添加路由规则
23+
24+
```swift
25+
// 路由规则
26+
Khala.language = .cn
27+
Khala.rewrite.filters.append(RewriteFilter({ (item) -> KhalaURLValue in
28+
var urlComponents = URLComponents(url: item.url, resolvingAgainstBaseURL: true)
29+
urlComponents?.host = "Router_" + (item.url.host ?? "")
30+
urlComponents?.path = "/router_" + item.url.lastPathComponent
31+
item.url = urlComponents?.url ?? item.url
32+
return item
33+
}))
34+
```
35+
36+
3. ##### 修改路由函数
37+
38+
第一个参数修改为匿名.
39+
40+
from:
41+
42+
```
43+
@objc func router_location(params: [String:Any],closure: (_ info: [String:Any]) -> Void){
44+
...
45+
}
46+
```
47+
48+
to:
49+
50+
```swift
51+
@objc func router_location(_ params: [String:Any],closure: @escaping KhalaClosure){
52+
...
53+
}
54+
```
55+
56+
4. #### 完了.
57+
1258
## Require
1359

1460
- iOS 8.0+ / macOS 10.10+ / tvOS 9.0+ / watchOS 2.0+

0 commit comments

Comments
 (0)