我是 React 的新手.JS,我目前正在與 Node 一起使用,并且遇到了以下問題:我正在使用來自Mateal-UI的按鈕(Google的界面資產(chǎn) - 按鈕,菜單等),并且我在通過函數(shù)運(yùn)行的const中定義了按鈕的樣式(因?yàn)檫@是在他們自己的網(wǎng)站中聲明的方式,我不確定為什么我需要一個函數(shù)而不僅僅是調(diào)用const)。我正在做的是自定義我正在導(dǎo)入的按鈕的邊距,并在瀏覽器的預(yù)定義按鈕上將顯示為“無”,使其消失。我在一個名為 HookApi 的組件中插入了帶有樣式值的 const.js這是它的內(nèi)容:import React, { useState } from 'react';import '../App.css';import { makeStyles } from '@material-ui/core/styles';import Button from '@material-ui/core/Button';const useStyles = makeStyles((theme) => ({ root: { '& > *': { margin: theme.spacing(1), }, }, input: { display: 'none', }, })); export function UploadButtons() { const classes = useStyles();}這就是我在我的畫廊里.js(正在替換我的應(yīng)用程序.js用于測試目的)import React, { useState } from 'react';import './App.css';import { makeStyles } from '@material-ui/core/styles';import Button from '@material-ui/core/Button';import HookApi from './constants/HookApi';import { classes } from './constants/HookApi';class Gallery extends React.Component{ constructor(props) { super(props); } render() { return( <div className={classes.root}> <input accept="image/*" className={classes.input} id="contained-button-file" multiple type="file" /> <label htmlFor="contained-button-file"> <Button variant="contained" color="primary" component="span"> Upload </Button> </label> </div> ); }}export default Gallery;我不確定我是否在我的圖庫中以錯誤的方式導(dǎo)入了const.js但是當(dāng)我呈現(xiàn)頁面時,它會給我以下錯誤“類”不是從“HookApi”導(dǎo)出的 - 圖像
如何在 React 中調(diào)用常量值
呼喚遠(yuǎn)方
2022-09-16 21:13:23