小编ari*_*ain的帖子

错误:“next/image”上的 src 属性无效,主机名“res.cloudinary.com”未在“next.config.js”中的图像下配置

我正在创建一个对象数组,其中有一个名称为 的图像 src 属性coverSrc,并将其导出并导入到我的主要组件中。在我的主要组件中,我使用 Material UI CardMedia 组件来显示图像。但它给了我以下错误:

src 属性无效next/image,主机名“res.cloudinary.com”未在您的图像下配置next.config.js

data.js

export const dataList = [
{
    id: 1,
    title: "Dim Sums",
    serviceTime: "24-30min",
    deliveryFee: 1.5,
    category: "dish",
    cuisine: "chinese",
    rating: 2,
    price: 4100,
    coverSrc: "https://res.cloudinary.com/arifscloud/image/upload/v1625119382/image_apxesv.png",
  },
{
    id: 2,
    title: "Dim loups",
    serviceTime: "22-35min",
    deliveryFee: 1.3,
    category: "dish",
    cuisine: "italian",
    rating: 3,
    price: 3100,
    coverSrc: "https://res.cloudinary.com/arifscloud/image/upload/v1627596941/image_apiop.png",
  },
]
Run Code Online (Sandbox Code Playgroud)

ListItem.jsx

import {
  Card,
  CardHeader,
  Avatar,
  CardMedia,
  CardContent,
  Typography,
} from "@material-ui/core";
import React from "react"; …
Run Code Online (Sandbox Code Playgroud)

next.js nextjs-image

12
推荐指数
1
解决办法
2万
查看次数

属性“src”的类型在 nextjs/image 中不兼容

我正在使用 react dropzone 在我的简单应用程序中上传多图像。为了显示哪种类型的图像被删除,我使用 TypeScript 制作了一个单独的组件。但是 Next.js 图像 src 显示错误,如类型:

'{ src: string; alt: string; }' is not assignable to type 'IntrinsicAttributes & ImageProps'.
  Type '{ src: string; alt: string; }' is not assignable to type 'ObjectImageProps'.
    Types of property 'src' are incompatible.
      Type 'string' is not assignable to type 'StaticImport'.
Run Code Online (Sandbox Code Playgroud)

渲染文件.ts:

'{ src: string; alt: string; }' is not assignable to type 'IntrinsicAttributes & ImageProps'.
  Type '{ src: string; alt: string; }' is not assignable to type 'ObjectImageProps'.
    Types …
Run Code Online (Sandbox Code Playgroud)

typescript next.js nextjs-image

10
推荐指数
2
解决办法
2204
查看次数

类型错误: apiRef.current.updateRows 不是材料 ui 数据网格中的函数

我想使用 Material UI 制作一个数据网格表。用户可以在其中更新表单提交中的特定行数据。对于性能问题,我想添加来自“material-ui/data-grid”的useGridApiRef。但我面临 ap​​iRef.current.updateRows 不是这个 prblm 的函数。这是我的代码:

  import { rows, columns } from "./helperData.js";
  import { DataGrid, useGridApiRef } from "@material-ui/data-grid";
    const DataGridPractice = () => {
      const [data, setData] = useState(rows)
      const [currentRow, setCurrentRow] = useState(null);
      const [showDialog, setShowDialog] = useState(false);
      const [isSending, setIsSending] = useState(false)
      const apiRef = useGridApiRef()
      const handleChange = e => {
        setCurrentRow({...currentRow, [e.target.name]: e.target.value})
      }
      const updateRow = () => {
        //  const updateRows = data.map((item) => item.id === currentRow.id ? currentRow : …
Run Code Online (Sandbox Code Playgroud)

datagrid material-ui

5
推荐指数
1
解决办法
1万
查看次数