小编Den*_*ash的帖子

如何在 kotlin 中使用 File.walk

file.walkI\xe2\x80\x99m 尝试使用以下方式进入文件夹:

\n\n
File.walk(FileWalkDirection.BOTTOM_UP).forEach()\n
Run Code Online (Sandbox Code Playgroud)\n\n

文档说:

\n\n
\n

kotlin.io.FileWalkDirection 中定义的枚举条目 BOTTOM_UP

\n\n

深度优先搜索,在文件之后访问目录

\n\n

枚举常量序数:1

\n
\n\n

如果我使用FileWalkDirection.BOTTOM_UP它\xe2\x80\x99s我的打印行走

\n\n
emergency-support/digital/beginner/.category.yml\nemergency-support/digital/.category.yml\nemergency-support/physical/beginner/.category.yml\nemergency-support/physical/.category.yml\nemergency-support/.category.yml\n
Run Code Online (Sandbox Code Playgroud)\n\n

我想为这个结果而步行:

\n\n
emergency-support/.category.yml\nemergency-support/physical/.category.yml\nemergency-support/physical/beginner/.category.yml\nemergency-support/digital/.category.yml\nemergency-support/digital/beginner/.category.yml\n
Run Code Online (Sandbox Code Playgroud)\n\n

如何在目录之前访问文件?

\n

kotlin

6
推荐指数
1
解决办法
8318
查看次数

Promisifying Sheet API v4 导致 undefined this

如果我使用回调,下面使用Google 的 Sheets API v4的代码可以正常工作。

但是,我正在尝试申请util.promisifyAPI 调用。这引起:

Cannot read property 'getRoot' of undefined
Run Code Online (Sandbox Code Playgroud)

这是从:

node_modules\googleapis\build\src\apis\sheets\v4.js:592
Run Code Online (Sandbox Code Playgroud)

这行 592 说: context: this.getRoot()

我可能没有promisify正确使用,我希望这里有人可以帮助我。

我怀疑它可能与并发有关。

任何提示将不胜感激。

let {
  promisify
} = require('util');
let {
  google
} = require('googleapis');
let sheets = google.sheets('v4');
let credentials = require('./credentials.json')

let client = new google.auth.JWT(
  credentials.client_email, null, credentials.private_key, ['https://www.googleapis.com/auth/spreadsheets'])
client.authorize((err, tokens) => {
  if (err) {
    throw err;
  }
});

let endpoint = promisify(sheets.spreadsheets.values.get);

async function test() {

  let request = …
Run Code Online (Sandbox Code Playgroud)

javascript concurrency google-sheets node.js npm

5
推荐指数
1
解决办法
854
查看次数

通过预先签名的 url 上传 AWS S3 返回 400 错误请求

我正在尝试AWS s3通过向预签名 URL发出PUT 请求来上传文件。我已经在 s3 仪表板上配置了 CORS。

反应代码

  const submit = async () => {
    const response = await axios.get("http://localhost:8080/api/upload");
    console.log(response.data);
    const upload = await axios.put(response.data.url, file, {
      headers: {
        "Access-Control-Allow-Origin": "*",
        "Content-Type": file.type
      }
    });
  };
Run Code Online (Sandbox Code Playgroud)

Node.js 代码

const s3 = new AWS.S3({
  accessKeyId: config.aws.accessKeyId,
  secretAccessKey: config.aws.secretAccessKey
});
app.get("/api/upload", (req, res) => {
  const key = `${uuid()}.jpeg`;
  s3.getSignedUrl(
    "putObject",
    {
      Bucket: "bucket-name",
      ContentType: "image/jpeg",
      Key: key
    },
    (err, url) => {
      res.status(200).json({ key, url }); …
Run Code Online (Sandbox Code Playgroud)

javascript amazon-s3 node.js reactjs

5
推荐指数
1
解决办法
2041
查看次数

构建失败,出现本机反应异常

运行时的反应原生运行Android的我得到异常下面......它运行良好,我做了git pull,做了NPM词,之后,它是未来。新拉也没有变化。事实上,在执行 git Colon 之后,这也是同样的问题。它在 MAC 中运行良好。请帮助我被卡住了。

FAILURE:构建失败,出现异常。

* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
        is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
        Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:13:5-33:19 to override.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help …
Run Code Online (Sandbox Code Playgroud)

android react-native

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

如何从表外使用搜索过滤器?

我正在使用antd表。有没有办法可以在表外添加搜索过滤器并仍然在表中搜索?

演示

我在表格上方添加了一个输入字段。但我无法理解如何将其链接到antd. 我还为每列添加了搜索过滤器,但也希望在外面有一个单独的字段。列过滤器工作正常。

为了便于参考,我还将演示代码粘贴到此处:

import React from "react";
import ReactDOM from "react-dom";
import "antd/dist/antd.css";
import "./index.css";
import { Table, Input, Button, Icon } from "antd";
import Highlighter from "react-highlight-words";

const data = [
  {
    key: "1",
    name: "John Brown",
    age: 32,
    address: "New York No. 1 Lake Park"
  },
  {
    key: "2",
    name: "Joe Black",
    age: 42,
    address: "London No. 1 Lake Park"
  },
  {
    key: "3",
    name: "Jim Green",
    age: 32,
    address: "Sidney …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs antd

5
推荐指数
1
解决办法
5803
查看次数

使用 Material-ui 转换时如何修复“TypeError:无法读取未定义的属性“样式””错误

我试图在我的反应应用程序中使用转换,但每次我尝试使用任何转换模块时都会出现此错误:“TypeError:无法读取未定义的属性‘样式’”,

(匿名函数)node_modules/@material-ui/core/esm/Fade/Fade.js:83

  80 |     style: _extends({
  81 |       opacity: 0,
  82 |       visibility: state === 'exited' && !inProp ? 'hidden' : undefined
> 83 |     }, styles[state], style, children.props.style),
     | ^  84 |     ref: handleRef
  85 |   }, childProps));
  86 | });
Run Code Online (Sandbox Code Playgroud)

我尝试过不使用 es6 类样式方法,这实际上解决了问题,但我想使用 es6 类。

我认为这与我在顶部定义的样式变量有关,如下所示:

const styles = theme => ({
    typography: {
        marginTop: theme.spacing(2)
    }
});

class IndexPage extends Component {
    constructor(props) {
        super(props);
        this.state = {
            checked: false,
        }
    }

    render() {
        const {classes} = …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs material-ui

5
推荐指数
1
解决办法
7466
查看次数

在 React Hooks 中是否有设置状态的通用方法?如何管理多个状态?

我有一个问题,我是否可以useState在 React Hooks 中使用泛型,就像我可以在 React Components 中同时管理多个状态一样?

state = {
  input1: "",
  input2: "",
  input3: ""
  // .. more states
};

handleChange = (event) => {
  const { name, value } = event.target;
  this.setState({
    [name]: value,
  });
};
Run Code Online (Sandbox Code Playgroud)

javascript reactjs react-hooks

5
推荐指数
1
解决办法
7369
查看次数

在变量中存储常量值与在状态中存储有区别吗?

我注意到有几种方法可以在 React 功能组件中实现看似相同的事情。当您拥有仅在此组件内部需要的本质上的配置值(只是一个常量值,从未传入或修改)时,您可以只使用常规值,也const可以将其存储在组件的状态中。

标准变量:

function Example1() {
  const a = 1
  return <div>{ a }</div>
}
Run Code Online (Sandbox Code Playgroud)

存储状态:

function Example2() {
  const [a] = useState(1)
  return <div>{ a }</div>
}
Run Code Online (Sandbox Code Playgroud)

我的印象是,在幕后,这会导致 Example1 在每次渲染时创建一个变量然后处理它,而 Example2 将创建一次变量并保持它直到卸载组件。那是准确的吗?就性能/良好实践而言,这些方法中的一种是否更可取?

javascript reactjs react-hooks react-functional-component

5
推荐指数
2
解决办法
1693
查看次数

React Context Api 与本地存储

我有一些关于上下文 API 和本地存储的一般性问题困扰着我。

何时使用本地存储?何时使用 Context API,何时使用两者?

我知道要在刷新后保留数据,我需要诸如本地存储或会话存储之类的东西,那么我是否完全放弃了上下文 API 并将所有内容存储在本地存储中?这样我不仅可以存储数据还可以保持刷新?一些见解将非常有帮助。

有什么优点和缺点?

javascript local-storage reactjs context-api

5
推荐指数
1
解决办法
7899
查看次数

useEffect 缺少自定义钩子中带有 ref 的依赖项警告

在启用了彻底依赖规则的 React Typescript 中,当我定义一个 ref 并在效果内部使用它时,linter 就可以了:

const stringRef: RefObject<string> = useRef("Hello World!");
  
useEffect(() => {
  console.log(stringRef.current);
}, []) // no warning, the linter detects that I'm using a ref
Run Code Online (Sandbox Code Playgroud)

但是,当我将效果放在自定义钩子中时,linter 抱怨我应该在依赖项数组中包含 ref:

const stringRef: RefObject<string> = useRef("Hello World!");
  
useCustomHook(stringRef);

// in another-file.ts
const useCustomHook = (ref: RefObject<string>) => {
  useEffect(() => {
    console.log(ref.current);
  }, []) // ESLint: React Hook useEffect has a missing dependency: 'ref'. Either include it or remove the dependency array.(react-hooks/exhaustive-deps)
}
Run Code Online (Sandbox Code Playgroud)

从语义上讲,没有任何变化,但是,linter 无法识别 ref 是 RefObject(即使我是这样输入的)。 …

javascript ref reactjs eslint react-hooks

5
推荐指数
1
解决办法
194
查看次数