我正在使用React ES6應用程序。es6變成字符串
是否可以聲明一個變量作爲變量名,如下面的refInput一樣?
renderInput(inputName) {
const refInput = `${inputName}Input`;
return (
<Input
ref={(node) => {
this.refInput = node;
}}
/>
);
}
任何幫助表示讚賞,我真的與此
您可以動態構造對象屬性名稱,但不能變量名稱。 – Pointy
你在尋找'this [refInput] = node;'? –