先安装插件
cordova-plugin-wkwebview-engine
然后修改插件中CDVWKWebViewEngine.m文件,下面是全部代码,修改部分已经进行注释
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
#import "CDVWKWebViewEngine.h"
#import "CDVWKWebViewUIDelegate.h"
#import "CDVWKProcessPoolFactory.h"
#import <Cordova/NSDictionary+CordovaPreferences.h>
#import <objc/message.h>
#define CDV_BRIDGE_NAME @"cordova"
#define CDV_WKWEBVIEW_FILE_URL_LOAD_SELECTOR @"loadFileURL:allowingReadAccessToURL:"
@interface CDVWKWeakScriptMessageHandler : NSObject <WKScriptMessageHandler>
@property (nonatomic, weak, readonly) id<WKScriptMessageHandler>scriptMessageHandler;
- (instancetype)initWithScriptMessageHandler:(id<WKScriptMessageHandler>)scriptMessageHandler;
@end
@interface CDVWKWebViewEngine ()
@property (nonatomic, strong, readwrite) UIView* engineWebView;
@property (nonatomic, strong, readwrite) id <WKUIDelegate> uiDelegate;
@property (nonatomic, weak) id <WKScriptMessageHandler> weakScriptMessageHandler;
@end
// see forwardingTargetForSelector: selector comment for the reason for this pragma
#pragma clang diagnostic ignored "-Wprotocol"
@implementation CDVWKWebViewEngine
@synthesize engineWebView = _engineWebView;
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super init];
if (self) {
if (NSClassFromString(@"WKWebView") == nil) {
return nil;
}
self.engineWebView = [[WKWebView alloc] initWithFrame:frame];
}
return self;
}
- (WKWebViewConfiguration*) createConfigurationFromSettings:(NSDictionary*)settings
{
WKWebViewConfiguration* configuration = [[WKWebViewConfiguration alloc] init];
configuration.processPool = [[CDVWKProcessPoolFactory sharedFactory] sharedProcessPool];
if (settings == nil) {
return configuration;
}
configuration.allowsInlineMediaPlayback = [settings cordovaBoolSettingForKey:@"AllowInlineMediaPlayback" defaultValue:NO];
configuration.mediaPlaybackRequiresUserAction = [settings cordovaBoolSettingForKey:@"MediaPlaybackRequiresUserAction" defaultValue:YES];
configuration.suppressesIncrementalRendering = [settings cordovaBoolSettingForKey:@"SuppressesIncrementalRendering" defaultValue:NO];
configuration.mediaPlaybackAllowsAirPlay = [settings cordovaBoolSettingForKey:@"MediaPlaybackAllowsAirPlay" defaultValue:YES];
return configuration;
}
- (void)pluginInitialize
{
// viewController would be available now. we attempt to set all possible delegates to it, by default
NSDictionary* settings = self.commandDelegate.settings;
self.uiDelegate = [[CDVWKWebViewUIDelegate alloc] initWithTitle:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"]];
CDVWKWeakScriptMessageHandler *weakScriptMessageHandler = [[CDVWKWeakScriptMessageHandler alloc] initWithScriptMessageHandler:self];
WKUserContentController* userContentController = [[WKUserContentController alloc] init];
[userContentController addScriptMessageHandler:weakScriptMessageHandler name:CDV_BRIDGE_NAME];
WKWebViewConfiguration* configuration = [self createConfigurationFromSettings:settings];
configuration.userContentController = userContentController;
// re-create WKWebView, since we need to update configuration
WKWebView* wkWebView = [[WKWebView alloc] initWithFrame:self.engineWebView.frame configuration:configuration];
//------------added begin-------------
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
if (@available(iOS 11.0, *)) {
[wkWebView.scrollView setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];
}
#endif
//------------added end----------------
wkWebView.UIDelegate = self.uiDelegate;
self.engineWebView = wkWebView;
if (IsAtLeastiOSVersion(@"9.0") && [self.viewController isKindOfClass:[CDVViewController class]]) {
wkWebView.customUserAgent = ((CDVViewController*) self.viewController).userAgent;
}
if ([self.viewController conformsToProtocol:@protocol(WKUIDelegate)]) {
wkWebView.UIDelegate = (id <WKUIDelegate>)self.viewController;
}
if ([self.viewController conformsToProtocol:@protocol(WKNavigationDelegate)]) {
wkWebView.navigationDelegate = (id <WKNavigationDelegate>)self.viewController;
} else {
wkWebView.navigationDelegate = (id <WKNavigationDelegate>)self;
}
if ([self.viewController conformsToProtocol:@protocol(WKScriptMessageHandler)]) {
[wkWebView.configuration.userContentController addScriptMessageHandler:(id < WKScriptMessageHandler >)self.viewController name:CDV_BRIDGE_NAME];
}
[self updateSettings:settings];
// check if content thread has died on resume
NSLog(@"%@", @"CDVWKWebViewEngine will reload WKWebView if required on resume");
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(onAppWillEnterForeground:)
name:UIApplicationWillEnterForegroundNotification object:nil];
NSLog(@"Using WKWebView");
[self addURLObserver];
}
- (void)onReset {
[self addURLObserver];
}
static void * KVOContext = &KVOContext;
- (void)addURLObserver {
if(!IsAtLeastiOSVersion(@"9.0")){
[self.webView addObserver:self forKeyPath:@"URL" options:0 context:KVOContext];
}
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSString *,id> *)change context:(void *)context
{
if (context == KVOContext) {
if (object == [self webView] && [keyPath isEqualToString: @"URL"] && [object valueForKeyPath:keyPath] == nil){
NSLog(@"URL is nil. Reloading WKWebView");
[(WKWebView*)_engineWebView reload];
}
} else {
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
}
}
- (void) onAppWillEnterForeground:(NSNotification*)notification {
if ([self shouldReloadWebView]) {
NSLog(@"%@", @"CDVWKWebViewEngine reloading!");
[(WKWebView*)_engineWebView reload];
}
}
- (BOOL)shouldReloadWebView
{
WKWebView* wkWebView = (WKWebView*)_engineWebView;
return [self shouldReloadWebView:wkWebView.URL title:wkWebView.title];
}
- (BOOL)shouldReloadWebView:(NSURL*)location title:(NSString*)title
{
BOOL title_is_nil = (title == nil);
BOOL location_is_blank = [[location absoluteString] isEqualToString:@"about:blank"];
BOOL reload = (title_is_nil || location_is_blank);
#ifdef DEBUG
NSLog(@"%@", @"CDVWKWebViewEngine shouldReloadWebView::");
NSLog(@"CDVWKWebViewEngine shouldReloadWebView title: %@", title);
NSLog(@"CDVWKWebViewEngine shouldReloadWebView location: %@", [location absoluteString]);
NSLog(@"CDVWKWebViewEngine shouldReloadWebView reload: %u", reload);
#endif
return reload;
}
- (id)loadRequest:(NSURLRequest*)request
{
if ([self canLoadRequest:request]) { // can load, differentiate between file urls and other schemes
if (request.URL.fileURL) {
SEL wk_sel = NSSelectorFromString(CDV_WKWEBVIEW_FILE_URL_LOAD_SELECTOR);
NSURL* readAccessUrl = [request.URL URLByDeletingLastPathComponent];
return ((id (*)(id, SEL, id, id))objc_msgSend)(_engineWebView, wk_sel, request.URL, readAccessUrl);
} else {
return [(WKWebView*)_engineWebView loadRequest:request];
}
} else { // can't load, print out error
NSString* errorHtml = [NSString stringWithFormat:
@"<!doctype html>"
@"<title>Error</title>"
@"<div style='font-size:2em'>"
@" <p>The WebView engine '%@' is unable to load the request: %@</p>"
@" <p>Most likely the cause of the error is that the loading of file urls is not supported in iOS %@.</p>"
@"</div>",
NSStringFromClass([self class]),
[request.URL description],
[[UIDevice currentDevice] systemVersion]
];
return [self loadHTMLString:errorHtml baseURL:nil];
}
}
- (id)loadHTMLString:(NSString*)string baseURL:(NSURL*)baseURL
{
return [(WKWebView*)_engineWebView loadHTMLString:string baseURL:baseURL];
}
- (NSURL*) URL
{
return [(WKWebView*)_engineWebView URL];
}
- (BOOL) canLoadRequest:(NSURLRequest*)request
{
// See: https://issues.apache.org/jira/browse/CB-9636
SEL wk_sel = NSSelectorFromString(CDV_WKWEBVIEW_FILE_URL_LOAD_SELECTOR);
// if it's a file URL, check whether WKWebView has the selector (which is in iOS 9 and up only)
if (request.URL.fileURL) {
return [_engineWebView respondsToSelector:wk_sel];
} else {
return YES;
}
}
- (void)updateSettings:(NSDictionary*)settings
{
WKWebView* wkWebView = (WKWebView*)_engineWebView;
wkWebView.configuration.preferences.minimumFontSize = [settings cordovaFloatSettingForKey:@"MinimumFontSize" defaultValue:0.0];
/*
wkWebView.configuration.preferences.javaScriptEnabled = [settings cordovaBoolSettingForKey:@"JavaScriptEnabled" default:YES];
wkWebView.configuration.preferences.javaScriptCanOpenWindowsAutomatically = [settings cordovaBoolSettingForKey:@"JavaScriptCanOpenWindowsAutomatically" default:NO];
*/
// By default, DisallowOverscroll is false (thus bounce is allowed)
BOOL bounceAllowed = !([settings cordovaBoolSettingForKey:@"DisallowOverscroll" defaultValue:NO]);
// prevent webView from bouncing
if (!bounceAllowed) {
if ([wkWebView respondsToSelector:@selector(scrollView)]) {
((UIScrollView*)[wkWebView scrollView]).bounces = NO;
} else {
for (id subview in wkWebView.subviews) {
if ([[subview class] isSubclassOfClass:[UIScrollView class]]) {
((UIScrollView*)subview).bounces = NO;
}
}
}
}
NSString* decelerationSetting = [settings cordovaSettingForKey:@"WKWebViewDecelerationSpeed"];
if (!decelerationSetting) {
// Fallback to the UIWebView-named preference
decelerationSetting = [settings cordovaSettingForKey:@"UIWebViewDecelerationSpeed"];
}
if (![@"fast" isEqualToString:decelerationSetting]) {
[wkWebView.scrollView setDecelerationRate:UIScrollViewDecelerationRateNormal];
} else {
[wkWebView.scrollView setDecelerationRate:UIScrollViewDecelerationRateFast];
}
wkWebView.allowsBackForwardNavigationGestures = [settings cordovaBoolSettingForKey:@"AllowBackForwardNavigationGestures" defaultValue:NO];
}
- (void)updateWithInfo:(NSDictionary*)info
{
NSDictionary* scriptMessageHandlers = [info objectForKey:kCDVWebViewEngineScriptMessageHandlers];
NSDictionary* settings = [info objectForKey:kCDVWebViewEngineWebViewPreferences];
id navigationDelegate = [info objectForKey:kCDVWebViewEngineWKNavigationDelegate];
id uiDelegate = [info objectForKey:kCDVWebViewEngineWKUIDelegate];
WKWebView* wkWebView = (WKWebView*)_engineWebView;
if (scriptMessageHandlers && [scriptMessageHandlers isKindOfClass:[NSDictionary class]]) {
NSArray* allKeys = [scriptMessageHandlers allKeys];
for (NSString* key in allKeys) {
id object = [scriptMessageHandlers objectForKey:key];
if ([object conformsToProtocol:@protocol(WKScriptMessageHandler)]) {
[wkWebView.configuration.userContentController addScriptMessageHandler:object name:key];
}
}
}
if (navigationDelegate && [navigationDelegate conformsToProtocol:@protocol(WKNavigationDelegate)]) {
wkWebView.navigationDelegate = navigationDelegate;
}
if (uiDelegate && [uiDelegate conformsToProtocol:@protocol(WKUIDelegate)]) {
wkWebView.UIDelegate = uiDelegate;
}
if (settings && [settings isKindOfClass:[NSDictionary class]]) {
[self updateSettings:settings];
}
}
// This forwards the methods that are in the header that are not implemented here.
// Both WKWebView and UIWebView implement the below:
// loadHTMLString:baseURL:
// loadRequest:
- (id)forwardingTargetForSelector:(SEL)aSelector
{
return _engineWebView;
}
- (UIView*)webView
{
return self.engineWebView;
}
#pragma mark WKScriptMessageHandler implementation
- (void)userContentController:(WKUserContentController*)userContentController didReceiveScriptMessage:(WKScriptMessage*)message
{
if (![message.name isEqualToString:CDV_BRIDGE_NAME]) {
return;
}
CDVViewController* vc = (CDVViewController*)self.viewController;
NSArray* jsonEntry = message.body; // NSString:callbackId, NSString:service, NSString:action, NSArray:args
CDVInvokedUrlCommand* command = [CDVInvokedUrlCommand commandFromJson:jsonEntry];
CDV_EXEC_LOG(@"Exec(%@): Calling %@.%@", command.callbackId, command.className, command.methodName);
if (![vc.commandQueue execute:command]) {
#ifdef DEBUG
NSError* error = nil;
NSString* commandJson = nil;
NSData* jsonData = [NSJSONSerialization dataWithJSONObject:jsonEntry
options:0
error:&error];
if (error == nil) {
commandJson = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
}
static NSUInteger maxLogLength = 1024;
NSString* commandString = ([commandJson length] > maxLogLength) ?
[NSString stringWithFormat : @"%@[...]", [commandJson substringToIndex:maxLogLength]] :
commandJson;
NSLog(@"FAILED pluginJSON = %@", commandString);
#endif
}
}
#pragma mark WKNavigationDelegate implementation
- (void)webView:(WKWebView*)webView didStartProvisionalNavigation:(WKNavigation*)navigation
{
[[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginResetNotification object:webView]];
}
- (void)webView:(WKWebView*)webView didFinishNavigation:(WKNavigation*)navigation
{
CDVViewController* vc = (CDVViewController*)self.viewController;
[CDVUserAgentUtil releaseLock:vc.userAgentLockToken];
[[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPageDidLoadNotification object:webView]];
}
- (void)webView:(WKWebView*)theWebView didFailProvisionalNavigation:(WKNavigation*)navigation withError:(NSError*)error
{
[self webView:theWebView didFailNavigation:navigation withError:error];
}
- (void)webView:(WKWebView*)theWebView didFailNavigation:(WKNavigation*)navigation withError:(NSError*)error
{
CDVViewController* vc = (CDVViewController*)self.viewController;
[CDVUserAgentUtil releaseLock:vc.userAgentLockToken];
NSString* message = [NSString stringWithFormat:@"Failed to load webpage with error: %@", [error localizedDescription]];
NSLog(@"%@", message);
NSURL* errorUrl = vc.errorURL;
if (errorUrl) {
errorUrl = [NSURL URLWithString:[NSString stringWithFormat:@"?error=%@", [message stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]] relativeToURL:errorUrl];
NSLog(@"%@", [errorUrl absoluteString]);
[theWebView loadRequest:[NSURLRequest requestWithURL:errorUrl]];
}
}
- (void)webViewWebContentProcessDidTerminate:(WKWebView *)webView
{
[webView reload];
}
- (BOOL)defaultResourcePolicyForURL:(NSURL*)url
{
// all file:// urls are allowed
if ([url isFileURL]) {
return YES;
}
return NO;
}
- (void) webView: (WKWebView *) webView decidePolicyForNavigationAction: (WKNavigationAction*) navigationAction decisionHandler: (void (^)(WKNavigationActionPolicy)) decisionHandler
{
NSURL* url = [navigationAction.request URL];
CDVViewController* vc = (CDVViewController*)self.viewController;
//------------added begin 修改开始-------------
NSString *scheme = [url scheme];
UIApplication *app = [UIApplication sharedApplication];
//电话,短信,邮件
if ([scheme isEqualToString:@"tel"]||[scheme isEqualToString:@"sms"] ||[scheme isEqualToString:@"mailto"]) {
if ([app canOpenURL:url]) {
CGFloat version = [[[UIDevice currentDevice]systemVersion]floatValue];
if (version >= 10.0) {
/// 大于等于10.0系统使用此openURL方法
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
} else {
[[UIApplication sharedApplication] openURL:url];
}
}
}
// 打开appstore
if ([url.absoluteString containsString:@"ituns.apple.com"]) {
if ([app canOpenURL:url]) {
[app openURL:url];
decisionHandler(WKNavigationActionPolicyCancel);
return;
}
}
//------------added end 修改结束-------------
/*
* Give plugins the chance to handle the url
*/
BOOL anyPluginsResponded = NO;
BOOL shouldAllowRequest = NO;
for (NSString* pluginName in vc.pluginObjects) {
CDVPlugin* plugin = [vc.pluginObjects objectForKey:pluginName];
SEL selector = NSSelectorFromString(@"shouldOverrideLoadWithRequest:navigationType:");
if ([plugin respondsToSelector:selector]) {
anyPluginsResponded = YES;
// https://issues.apache.org/jira/browse/CB-12497
int navType = (int)navigationAction.navigationType;
if (WKNavigationTypeOther == navigationAction.navigationType) {
navType = (int)UIWebViewNavigationTypeOther;
}
shouldAllowRequest = (((BOOL (*)(id, SEL, id, int))objc_msgSend)(plugin, selector, navigationAction.request, navType));
if (!shouldAllowRequest) {
break;
}
}
}
if (anyPluginsResponded) {
return decisionHandler(shouldAllowRequest);
}
/*
* Handle all other types of urls (tel:, sms:), and requests to load a url in the main webview.
*/
BOOL shouldAllowNavigation = [self defaultResourcePolicyForURL:url];
if (shouldAllowNavigation) {
return decisionHandler(YES);
} else {
[[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]];
}
return decisionHandler(NO);
}
#pragma mark - Plugin interface
- (void)allowsBackForwardNavigationGestures:(CDVInvokedUrlCommand*)command;
{
id value = [command argumentAtIndex:0];
if (!([value isKindOfClass:[NSNumber class]])) {
value = [NSNumber numberWithBool:NO];
}
WKWebView* wkWebView = (WKWebView*)_engineWebView;
wkWebView.allowsBackForwardNavigationGestures = [value boolValue];
}
@end
#pragma mark - CDVWKWeakScriptMessageHandler
@implementation CDVWKWeakScriptMessageHandler
- (instancetype)initWithScriptMessageHandler:(id<WKScriptMessageHandler>)scriptMessageHandler
{
self = [super init];
if (self) {
_scriptMessageHandler = scriptMessageHandler;
}
return self;
}
- (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message
{
[self.scriptMessageHandler userContentController:userContentController didReceiveScriptMessage:message];
}
@end
- Web App适配iPhoneX
前言 Iphone每次退出新尺寸的手机都会掀起一番适配风波,这次没有下巴但有刘海的iPhoneX更是如此,网传横屏下的适配动画更是令不少人汗颜. 其实对于Native App来说,适配并不算困难(当然 ...
- H5网页适配 iPhoneX,就是这么简单
iPhoneX 取消了物理按键,改成底部小黑条,这一改动导致网页出现了比较尴尬的屏幕适配问题.对于网页而言,顶部(刘海部位)的适配问题浏览器已经做了处理,所以我们只需要关注底部与小黑条的适配问题即可( ...
- H5网页适配 iPhoneX,就是这么简单(转)
iPhoneX 取消了物理按键,改成底部小黑条,这一改动导致网页出现了比较尴尬的屏幕适配问题.对于网页而言,顶部(刘海部位)的适配问题浏览器已经做了处理,所以我们只需要关注底部与小黑条的适配问题即可( ...
- 【css】适配iphoneX
/*适配iphoneX*/ @media only screen and (device-width: 375px) and (device-height: 812px) and (-webkit-d ...
- 手机端适配iPhoneX
iPhoneX取消了物理按键,改成底部小黑条,这一改动导致网页出现比较尴尬的屏幕适配问题.对于网页而言,顶部(刘海部位)的适配问题浏览器已经做了处理,所以我们只需要关注底部与小黑条的适配问题即可(即常 ...
- 适配iphoneX
tips iphone6设备宽高为375×667,屏幕分辨率为750×1334,故其设备像素比(dpr)为2.iphoneX的设备宽高375*812,屏幕分辨率为1125x2436,故dpr=3 适配 ...
- cordova 实现拨打电话-只需两步(H5)
cordova 实现拨打电话: 第一步配置conf.xml在cordova中所有的URL Schemes 都是服从于白名单的,所以a tel 在这无法正常使用.解决方法是在项目config.xml中添 ...
- lib-flexible 结合 WKWebView 的样式错乱解决方法
技术栈 lib-flexible 是淘宝的可伸缩方案 WKWebView 是ios8以上支持的网页控件 问题场景 最新公司一个项目使用 lib-flexible 来做移动端的伸缩解决方案,页面在saf ...
- 87、代码适配IphoneX
一.APP在iphoneX运行后不能占满,上下都有多余的边 解决方法:把旧的image.xcassets中的LaunchImage删掉,重新创建并在Images.xcassets中为iPhone X添 ...
随机推荐
- 为Azure Web Site 添加ADFS验证支持之一 设置ADFS的信任关系
很多时候企业开发的应用都会通过AD(Active Directory)进行验证用户名密码的,在企业里面统一一个AD来进行账号密码管理也是一个很好的实践.当企业打算将一个应用迁移到Azure的时候,使用 ...
- git分支管理图
- ZOJ 3781 Paint the Grid Reloaded 连通块
LINK:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3781 题意:n*m只由OX组成的矩阵,可以选择某一连通块变成另一 ...
- 《JavaScript 实战》:实现拖放(Drag & Drop)效果
拖放效果,也叫拖拽.拖动,学名Drag-and-drop ,是最常见的js特效之一.如果忽略很多细节,实现起来很简单,但往往细节才是难点所在.这个程序的原型是在做图片切割效果的时候做出来的,那时参考了 ...
- 【BZOJ】1066: [SCOI2007]蜥蜴
[算法]网络流-最大流(dinic) [题解] 构图思路: 因为石柱高度是可以被消耗的,即一根石柱可通过的蜥蜴数量有限,取舍问题中这样表示容量的属性显然可以作为网络流中的边. 于是将一根石柱拆成顶部和 ...
- 【leetcode 简单】第三十六题 最小栈
设计一个支持 push,pop,top 操作,并能在常数时间内检索到最小元素的栈. push(x) -- 将元素 x 推入栈中. pop() -- 删除栈顶的元素. top() -- 获取栈顶元素. ...
- 简易版jquery
最近写了一个简易版的jquery github地址:https://github.com/jiangzhenfei/Easy-Jquery 完成的方法: 1.$('#id') 2.extend扩展 ...
- C++ Boost库 uBLAS 笔记
构造 Vector #include <boost/numeric/ublas/vector.hpp> #include <boost/numeric/ublas/io.hpp> ...
- spring boot 加载原理
spring boot quick start 在springBoot里面,很吸引的一个特征就是可以直接把应用打包成jar/war包形式.然后jar/war包可以直接运行的.不需要再配置web Ser ...
- Perl6多线程4: Promise allof / anyof
allof : 所有代码块执行完成后才退出 anyof :只要有一个代码块执行完后就马上退出 要配合 await 一起用: my $p = start {say 'a'}; ;say 'b';} ...