javascript - 这个状态管理可以在react上做吗?
解决方案
首先,请在问题中发布您的代码并清楚地描述
使用 getLabels 函数,您应该在构造函数中绑定(this)或使用箭头函数,然后您可以在 getLabels 函数中使用 this.setState。前任:
constructor(props){
super(props)
this.getLabels = this.getLabels.bind(this)
}
或者:getLabels = () => {}
推荐阅读
- node.js - 如何在 ADFS(作为 IDP)metadata.xml 中包含配置的声明或提前知道它们(在返回配置文件对象之前)?
- node.js - Mongoose Schema如何在数据库更新时更改date.now
- java - Xamarin Android Java 绑定库遭受运行时 OutOfMemoryError
- postgresql - 在 Postgres 中使用解释分析创建一个函数来检查执行时间
- c++ - 如何将 Ehlers 的 StochasticRSI 指标从 mql4 移植到 C++(从 MT4 到 QChartist)?
- mongodb - 对于聚合 Spring Data Mongo 中的嵌套文档,标准中的运算符无法按预期工作
- microsoft-graph-api - 适用于教育的 Office 365 开发人员计划
- php - 如果这个但不是这个而不是这个
- parsing - 解析器的一些网址
- string - 为什么子字符串提取提取整个单词而不是字符?