reactjs - 尝试为权重对象创建唯一 ID
问题描述
我正在尝试为构造函数中的权重对象创建唯一 ID(我不能使用任何唯一 ID 库,我只能使用 math.random 函数),然后将其传递给渲染方法。
constructor(props){
super(props);
const localDB = loadState();
this.state = {
username: localDB.account,
PrivateKey: localDB.key,
author: this.props.author,
permlink: this.props.permlink,
expanded: false,
weight : this.props.weight
};
return (
<div className="upvote">
<div id="upVote"><br /><input id="expandVote" type="button" value="Open voting UI" onClick={() => this.expandDropdown()} /></div>
{ this.state.expanded ? <input id="this.state.weight" defaultValue="10" /> : null }
{ this.state.expanded ? <button id="pushVote" onClick={() => this.pushVote()}>Push vote</button> : null }
{ this.state.expanded ? <button id="closeVote" onClick={this.closeDropdown}>Close voting UI</button> : null }
</div>
)
}
解决方案
推荐阅读
- php - 您好,我只想将登录的用户 ID 添加到我的苹果表中,一切正常,但 user_id 表没有获取用户 ID
- android - 在 ImageView 上设置位图 - 无法创建带有消息“未实现”的图像解码器
- javascript - Tryint 在 JavaScript 中将 BigInt 转换为十六进制
- caching - 在“延迟值表”中:每一级缓存的延迟值是否包括上一级缓存的访问?
- c# - 尝试更新嵌套数组时出现 Mongo 错误:未找到标识符的数组过滤器
- python - 如何从列表中创建 x,y 对
- java - 找不到以下类: - android.support.v7.widget.RecyclerView
- c# - 在 Unity 2D 编辑器中,即使我告诉它,我的 UI 文本也没有改变
- flutter - 有没有办法从firestore中删除文件夹?
- python - 从日期序数数组设置日期刻度标签