我正在尝试编写一个抽象的 ReactJS 类,然后对其进行扩展。因此,我需要扩展它的props
和state
(据我所知;我是 React 的新手)。
基于Nitzan 的帖子展示了如何props
从基类扩展,我创建了一个抽象类Animal
:
import * as React from "react";
export interface AnimalProps {
isHibernatory: boolean;
}
export interface AnimalState {
shouldHibernate: boolean;
}
// TS2322: Type '{ shouldHibernate: boolean; }' is not assignable to type 'Readonly<S>'.
export abstract class Animal<P extends AnimalProps, S extends AnimalState>
extends React.Component<P, S> {
constructor(props: P) {
super(props);
this.state = {
shouldHibernate: props.isHibernatory
};
}
}
Run Code Online (Sandbox Code Playgroud)
......并且还制作了一个Cat
扩展它的类:
import * …
Run Code Online (Sandbox Code Playgroud) 在iOS Safari中单击“共享”按钮时(通过工具栏或长按链接),我希望我的应用程序显示为“在...中打开”选项(例如,“在新闻中打开” ”),以便我的应用(这是另一种网络浏览器)可以打开Safari共享的任何内容http://
或https://
URL。
我已经在苹果info.plist
文件中注册了文档类型“ URL”(我相信这是正确的类型,如果此假设是错误的,请更正!),我CFBundleDocumentTypes
可以从Apple的“注册应用程序支持的文件类型”文档中猜到,他们的技术问答以及与之相关的StackOverflow帖子1 2 3:
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeIconFiles</key>
<array>
<string>appIcon320</string>
<string>appIcon64</string>
</array>
<key>CFBundleTypeName</key>
<string>URL</string>
<key>CFBundleTypeRole</key>
<string>Editor</string> <!-- Note: I have also tried 'Viewer' -->
<key>LSHandlerRank</key>
<string>Owner</string> <!-- Note: I have also tried 'Default' -->
<key>LSItemContentTypes</key>
<array>
<string>public.url</string>
</array>
</dict>
</array>
Run Code Online (Sandbox Code Playgroud)
我也用以下代码编写了这个存根方法AppDelegate.swift
(尽管我认为实际上与使我的应用程序显示为“打开方式...”选项的第一阶段的成功无关):
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {opening-in-app-getting-uiapplicationlaunchoptionsurlkey-from-launchoptions?rq=1
print("Received URL: \(url); from …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用与我的 iOS 应用程序相同的 Swift 代码、沙盒测试人员和 iTunes Connect 帐户在 macOS 应用程序中运行应用程序内购买 (IAP)。但是,我无法让它工作。我使用的是 macOS High Sierra 10.13.6。
Apple 的 IAP 测试建议可在此处找到:
在开发 macOS 设备上,退出 Mac App Store。然后在 Xcode 中构建您的应用程序并从 Finder 启动它。
如果文本“[Environment: Sandbox]”没有出现,则您正在使用生产环境。确保您正在运行应用程序的开发签名版本。生产签名构建使用生产环境。
我按照这些步骤退出了 Mac App Store,并构建了我的应用程序——签名进行开发——然后从 Finder 启动它。不幸的是,这意味着我没有得到调试日志。
这是我的产品表:
我可以通过按“免费”按钮或“4.99 英镑”按钮来购买产品。
稍等片刻后,弹出此弹出窗口,提示“需要登录”。我使用我的沙盒测试人员之一登录(注意:我现在已经尝试了五个不同的测试帐户,所有这些帐户都在同一个 iTunes Connect 帐户下的 iOS 应用程序上运行),使用非Apple ID 的电子邮件地址注册:
选择“购买”后,稍等片刻,将出现下一个弹出窗口:
选择“取消”(此处推荐)后,稍等片刻后,将出现下一个弹出窗口:
您目前无权在 Sandbox 中购买此 InApp。
[环境:沙盒]
所以我不确定它是否让我登录,我假设我的购买失败了(我的表 UI 没有更新为“已购买”)。请注意,我也尝试在此处按“更改商店”,但最终仍然失败。
这一次,我没有提示登录;而是立即询问我是否愿意购买该产品。我点击“确认”。
但是,现在购买交易永远不会完成:
我可能做错了什么?我是否也需要登出任何东西(例如 iCloud)Settings > Internet Accounts
?
考虑 TypeScript 中的以下接口lib.d.ts
:
interface HTMLElement extends Element {
accessKey: string;
readonly children: HTMLCollection;
contentEditable: string;
readonly dataset: DOMStringMap;
dir: string;
draggable: boolean;
// ... many more
}
Run Code Online (Sandbox Code Playgroud)
我如何仅从该界面中选择不属于 的属性readonly
,而无需手动识别和输入所有属性(如下所示)?
type WriteableHTMLElProps = Pick<HTMLElement, "accessKey"|"contentEditable" /* ... */>
Run Code Online (Sandbox Code Playgroud)
注意:正确的解决方案还readonly
应该处理该扩展的接口的非属性。