簡體   English   中英

數據網格的父 DOM 元素具有空高度

[英]The parent DOM element of the data grid has an empty height

import React from 'react'
import { DataGrid } from '@mui/x-data-grid'
import Box from '@mui/material/Box'

export default function ManageAdmins() {

  const columns = [
    { field: 'no.', headerName: 'no.' },
    { field: 'id', headerName: 'id' },
    { field: 'avatar', headerName: 'Avatar' },
    { field: 'name', headerName: 'Name' },
    { field: 'active', headerName: 'active?' },
    { field: 'email', headerName: 'Login email' },
    { field: 'contactEmail', headerName: 'Contact email' },
    { field: 'actions', headerName: 'Actions' },
  ]

  return (
    <Box sx={{ height: '500px', width: '500px' }}>
      <DataGrid columns={columns} rows={[]} />
    </Box>
  )
}

我收到以下錯誤:

MUI:useResizeContainer - 數據網格的父 DOM 元素具有空高度。 請確保此元素具有固有高度。 網格顯示高度為 0 像素。

有什么問題?

你需要給它高度樣式

<div style={{height: '300px',width: '70%'}} >
  <DataGrid ......./>
</div>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM