有谁知道如何通过 MUI 5 SX prop 使用多个 CSS 类?我创建了一个基类,我想将其与 Box 组件一起使用,但使用第二个类专门用于 Box 内部的文本。应用基类,例如sx={styles.baseBoxStyle}可以工作但sx={styles.baseBoxStyle styles.customBoxFontStyle}返回错误。下面提供了完整的代码片段和沙箱。非常感谢任何帮助!
沙盒:https://codesandbox.io/s/mui-5-styling-uqt9m?file =/pages/index.js
import * as React from "react";
import Box from "@mui/material/Box";
const styles = {
baseBoxStyle: {
backgroundColor: "red",
borderRadius: "20px 20px 20px 20px",
border: "1px solid black",
maxWidth: "150px",
margin: "20px",
padding: "10px"
},
customBoxFontStyle: {
color: "yellow",
fontWeight: "bold"
}
};
export default function Index() {
return <Box sx={styles.baseBoxStyle styles.customBoxFontStyle}>This is a test</Box>;
}
Run Code Online (Sandbox Code Playgroud) 我无法以正确的方式进行编码,以便 formik.values 将反映到 Material UI 的复选框中
我创建了一个自定义的 PushViewController 方法,在转换完成后会进行回调。它可以在应用程序上运行,但不能使其在单元测试中运行。这是 UINavigationController 扩展:
extension UINavigationController {
public func pushViewController(_ viewController: UIViewController, animated: Bool, completion: @escaping (Void) -> Void) {
pushViewController(viewController, animated: animated)
guard animated, let coordinator = transitionCoordinator else {
completion()
return
}
coordinator.animate(alongsideTransition: nil) { _ in completion() }
}
}
Run Code Online (Sandbox Code Playgroud)
当我在单元测试中调用它时transitionCoordinator总是为零。我尝试设置一个窗口,将导航设置为根控制器,并使该窗口键可见。我也尝试过访问视图属性,以便加载 VC,但似乎没有任何效果。transitionCoordinator财产永远为零。
有任何想法吗?这是单元测试的预期行为吗?
总的来说,我对 React 和 UI 很陌生。
有人可以帮我纠正这个问题吗?
我在组件中使用 Material Ui 选项卡,但无法在禁用的选项卡之一上获得工具提示。(下面添加的代码片段)
<Tooltip title={sample_title}>
<span>
<Tab
disabled
value={some_Random_title}
classes={tabStyleOne}
label={
(
<Typography variant="caption" align="center" classes={renditionHeader}>
{some_random-text}
</Typography>
)
}
/>
</span>
</Tooltip>
Run Code Online (Sandbox Code Playgroud)
我按照 Material-UI 选项卡文档中针对禁用选项卡的要求将选项卡封装在 Span 中
https://codesandbox.io/s/wc74r?file=/demo.js
请帮助我理解我哪里做错了。以及如何在 Material UI 中的禁用选项卡上实现工具提示。
提前致谢。
我正在尝试将 getServerSideProps 方法从该页面导入到另一个页面,并在多个页面中使用它。我怎样才能做到这一点?
这是我的代码:
import DashboardLayout from "@app/layout/DashboardLayout";
import Overview from "@containers/dashboard/Overview";
import { parsedCookie } from "@infrastructure/utils/functions";
const OverviewPage = () => {
return (
<DashboardLayout>
<Overview />
</DashboardLayout>
);
};
export default OverviewPage;
export const getServerSideProps = async (context) => {
const token = parsedCookie(context.req);
const { accessToken, refreshToken } = token;
if (!accessToken || !refreshToken) {
return {
redirect: {
destination: "/",
permanent: false,
},
};
}
return {
props: {},
};
};
Run Code Online (Sandbox Code Playgroud) reactjs ×4
javascript ×3
material-ui ×3
checkbox ×1
css ×1
ecmascript-6 ×1
es6-modules ×1
formik ×1
ios ×1
next.js ×1
tabs ×1
tdd ×1
unit-testing ×1