这是函数。它给出了这个错误: - “string”类型的参数不能分配给“number”类型的参数
//index.js should be like this
render(){
const {contacts} = this.state;
return (
<div className="panel">
{contacts.map(contact => (
<div class="panel">
<Panel
key={contact.picture} user={contact.name} avatar={contact.picture.medium}
/>
<li class="flex-container">
<Button title="name" >
<p key={contact.name} user={contact.name}></p>
</Button>
<Button title="location" onClick={this.fetchdata}>
</Button>
<Button key={contact.email} title="email">
</Button>
<Button key={contact.phone} title="phone">
</Button>
<Button key={contact.login.password} title="password">
</Button>
</li>
</div>
))}
</div>
);
}
答案 0 :(得分:1)
您需要传递号码,但是您要传递0px
,所以只需使用此代码 -
b64EncodeUnicode(str) {
return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g,
function toSolidBytes(match, p1) {
return String.fromCharCode(0 + p1);
}));
}
答案 1 :(得分:0)
尝试在使用字符串之前将其转换为数字,如下所示:
return String.fromCharCode(Number('0x' + p1));