我正在使用 Next js 和 Material UI(@mui/core) 创建一个网站。当我使用 运行它时,它工作得很好next dev,但是当我使用 时,它得到了错误的样式next build && next start。除了 Material UI 之外,我还使用 CSS 模块来设计我的应用程序。
我在 Github 上找到了一个解决方案,说要在 中添加此代码_document.js,但这对我不起作用。
import * as React from "react";
import Document, { Html, Head, Main, NextScript } from "next/document";
import createEmotionServer from "@emotion/server/create-instance";
import theme from "../src/theme";
import createEmotionCache from "../src/createEmotionCache";
export default class MyDocument extends Document {
render() {
return (
<Html lang="en">
<Head>
{/* PWA primary color */}
<meta name="theme-color" content={theme.palette.primary.main} /> …Run Code Online (Sandbox Code Playgroud) 我正在尝试对我的组件进行排序
<input type="text" value={props.filters.text} onChange={(e) => {
props.dispatch(setTextFilter(e.target.value));
}} />
{console.log(props.filters.sortBy)}
<select value={props.filters.sortBy} onChange={(e) => {
if (e.target.value === 'date') {
props.dispatch(sortByDate());
} else if (e.target.value === 'amount') {
props.dispatch(sortByAmount());
}
}}>
<option value="amount">Amount</option>
<option value="date">Date</option>
</select>
Run Code Online (Sandbox Code Playgroud)
我在选择标签时遇到错误。最初获取A component is changing a controlled input of type text to be uncontrolled
props.filters.sortBy 的错误值是日期。当我尝试从下拉列表中更改它时,会发生错误。