我正在尝试阅读和写作,File System Web API但我不断发现TypeError Uncaught (in promise) TypeError: window.showOpenFilePicker is not a function,我不知道发生了什么。
这是反应代码片段:
const FileReader = () => {
const openThisFile = async () => {
const [fileHandle] = await window.showOpenFilePicker(); // error: Property 'showOpenFilePicker' does not exist on type 'Window & typeof globalThis'
console.log(fileHandle);
};
return (
<div>
<button onClick={openThisFile}>Open file</button>
</div>
);
};
export default FileReader;
Run Code Online (Sandbox Code Playgroud)
所以我认为它在 React 中不起作用,然后我尝试了 Vanilla Javascript,但我仍然不断进入TypeError Uncaught (in promise) TypeError: window.showOpenFilePicker is not a function …
我是 swift 编程语言的新手。我已经看到在 Swift 中创建表时,您必须在 ViewController 类中实现两个扩展UITableViewDelegate, 的方法UITableViewDataSource。我不明白的是,为什么 Xcode 的自动修复会func tableView在这个类中创建两个同名的方法?
这不会造成方法重载或导致错误吗?
import UIKit
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet var tableView: UITableView!
let dataArray = ["firt", "second", "third", "four", "five", "six"]
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return dataArray.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let videoCell = tableView.dequeueReusableCell(withIdentifier: "video title", for: indexPath)
return videoCell
}
override func viewDidLoad() {
super.viewDidLoad()
// Do …Run Code Online (Sandbox Code Playgroud)