第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在 React 中調(diào)用常量值

如何在 React 中調(diào)用常量值

呼喚遠(yuǎn)方 2022-09-16 21:13:23
我是 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)出的 - 圖像
查看完整描述

1 回答

?
GCT1015

TA貢獻(xiàn)1827條經(jīng)驗(yàn) 獲得超4個贊

您可以嘗試導(dǎo)出函數(shù),而不是導(dǎo)出 。const


圖庫.js


import UploadButtons from './constants/HookApi';


render() {

    const {input} = this.props.UploadButtons();

    //...other logic

    (<input

       accept="image/*"

       className={input}

       id="contained-button-file"

       multiple

       type="file"

    />)

  }

}


查看完整回答
反對 回復(fù) 2022-09-16
  • 1 回答
  • 0 關(guān)注
  • 141 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號