小编Lag*_*hen的帖子

未捕获(承诺中)类型错误:window.showOpenFilePicker 不是函数

未捕获(承诺中)类型错误:window.showOpenFilePicker() 不是函数

我正在尝试阅读和写作,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 …

javascript reactjs

11
推荐指数
1
解决办法
1万
查看次数

为什么 Xcode 自动修复创建两个具有相同名称`func tableView` 的方法?

我是 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)

uitableview ios swift

0
推荐指数
1
解决办法
57
查看次数

标签 统计

ios ×1

javascript ×1

reactjs ×1

swift ×1

uitableview ×1