即使在互联网上搜索我也没有找到,或者说我不明白。 我的问题:我希望在“InputField.js”组件中找到“inputVal”变量,其中有“!!HERE!!”在“App.js”组件中(在获取时) 请帮我 感谢您阅读我的留言!
export default function InputField() {
function handleSubmit(e) {
// Prevent the browser from reloading the page
e.preventDefault();
// Read the form data
const form = e.target;
const inputVal = form.myInput.value;
console.log(inputVal);
}
return (
);
}
import './App.css';
import AccountNumber from "./components/AccountNumber";
import InputField from "./components/InputField";
import { useEffect, useState } from "react"
function App() {
//token fetch
const [tockens, setTockens] = useState([])
const [loading, setLoading] = useState(false)
useEffect(() => {
setLoading(true)
fetch("https://api.multiversx.com/accounts/!!HERE!!/tokens")
.then(response => response.json())
.then(json => setTockens(json))
.finally(() => {
setLoading(false)
})
console.log(tockens);
}, [])
function round(nr, ten) { // arondi un chiffre.
return Math.round(nr * ten) / ten;
}
function numberWithSpaces(nr) { // formate un chiffre(x xxx xxx).
return nr.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ");
}
return (
Total number of accounts
{InputField()}
{window.inputVal}
{loading ? (
Loading...
) : (
<>
Tockens
Name
Price
Hold
{tockens.map(tocken => (
{tocken.name}
${round(tocken.price, 10000000)}
{round(tocken.balance / Math.pow(10, tocken.decimals), 10000000)}
${round(tocken.valueUsd, 10000000)}
))}
>
)}
);
}
export default App;
我的反应不太好,我在互联网上搜索
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号