小编Luk*_*eco的帖子

无法在 TypeScript 中自定义 Material UI 主题的调色板类型

我创建一个类型接口来将自定义属性添加到调色板,如下所示:

declare module @material-ui/core/styles/createMuiTheme {
  interface PaletteColor {
    transparent?: string;
    gradient?: PaletteColor;
  }
  interface Palette {
    gradient?: PaletteColor;
    transparent?: PaletteColor;
    secondary?: {
      transparent?: string;
    }
  }

  interface PaletteColorOptions {
    main?:string;
    dark?:string;
    light?:string;
    transparent?: string;
    gradient?: string;
    test?: string
  }
}
Run Code Online (Sandbox Code Playgroud)

我正在尝试很多接口来让它工作......

然后我在我的主题中使用这些类型,如下所示:

export default function createMyTheme(options: ThemeOptions) {
    return createMuiTheme({
      ...options,
    })
  }
Run Code Online (Sandbox Code Playgroud)

我使用该函数通过导入并调用它来创建我的主主​​题:

const theme = createMyTheme({});
Run Code Online (Sandbox Code Playgroud)

然后我像这样设置组件样式:background:theme.palette.gradient.main,

它告诉我:

Property 'gradient' does not exist on type 'Palette'.
Run Code Online (Sandbox Code Playgroud)

环境:“@material-ui/core”:“^4.9.2”,“react”:“^16.12.0”,“typescript”:“^3.7.5”

这是我的完整主题:

const theme = createMyTheme({
  palette: {
    primary: {
      main: '#5FB9A6', …
Run Code Online (Sandbox Code Playgroud)

typescript reactjs material-ui

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

解析服务器和 mongodb 问题

我正在尝试为我的快速应用程序设置解析服务器的本地安装。这是我所做的:

npm install -g parse-server mongodb-runner
Run Code Online (Sandbox Code Playgroud)

然后:

mongodb-runner start
Run Code Online (Sandbox Code Playgroud)

这触发了这个错误:

  Starting a MongoDB deployment to test against...{ HTTPError: Response code 403 (Forbidden)
at EventEmitter.ee.on.res (/usr/local/lib/node_modules/mongodb-runner/node_modules/got/index.js:250:24)
at EventEmitter.emit (events.js:182:13)
at Immediate.setImmediate (/usr/local/lib/node_modules/mongodb-runner/node_modules/got/index.js:99:8)
at runCallback (timers.js:705:18)
at tryOnImmediate (timers.js:676:5)
at processImmediate (timers.js:658:5)
name: 'HTTPError',
host: 'fastdl.mongodb.org',
hostname: 'fastdl.mongodb.org',
method: 'GET',
path: '/osx/mongodb-macos-x86_64-4.0.3.tgz',
protocol: 'https:',
url:
'https://fastdl.mongodb.org/osx/mongodb-macos-x86_64-4.0.3.tgz',
statusCode: 403,
statusMessage: 'Forbidden',
headers:
{ 'content-type': 'application/xml',
 'transfer-encoding': 'chunked',
 connection: 'close',
 date: 'Wed, 17 Oct 2018 18:38:43 GMT',
 server: 'AmazonS3',
 'x-cache': 'Error from cloudfront',
 via: …
Run Code Online (Sandbox Code Playgroud)

mongodb node.js parse-server

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