小编eak*_*akl的帖子

如何在 NPM 上创建仅限类型的包

我想创建一个仅导出类型的包(monorepo 或 NPM),以便在我的项目中我可以这样导入它们

import type { MyType } from '@acme/types'
Run Code Online (Sandbox Code Playgroud)

我已尝试以下解决方案,但它不起作用

项目结构

package.json
index.d.ts
Run Code Online (Sandbox Code Playgroud)

索引.d.ts

export type MyType = {
  name: string
}
Run Code Online (Sandbox Code Playgroud)

包.json

import type { MyType } from '@acme/types'
Run Code Online (Sandbox Code Playgroud)

当我想导入我的类型时,出现此错误

File '/Users/acme/packages/types/index.d.ts' is not a module. ts(2306)

我也尝试过重命名index.d.tsindex.ts. 也不起作用

npm typescript monorepo

7
推荐指数
1
解决办法
5203
查看次数

Material-UI 中的 notched 属性应该做什么

我正在一个项目中使用 Material-UI,并且正在浏览他们的 API。

但是,我不明白OutlineInput组件notched中的属性

<FormControl variant='outlined'>
  <OutlinedInput notched={false} />
</FormControl>
Run Code Online (Sandbox Code Playgroud)

将属性从 false切换notched为 true 不会在视觉上改变任何内容。

另外,由于我不是以英语为母语的人,我完全不明白它应该做什么。

html css reactjs material-ui

4
推荐指数
1
解决办法
3804
查看次数

在 Material UI 中使用多个 CSS 规则名称和样式化 API

我正在使用 Material UI,并且想使用多个规则名称和样式化 API来设置组件的样式来设置组件的样式。

假设我想设置FormLabel 组件的样式设置为蓝色,并将星号(必需)设置为红色。

使用Hook API我会做类似的事情:

import React from 'react'
import { makeStyles } from '@material-ui/core/styles'
import MuiFormLabel from '@material-ui/core/FormLabel'

const useStyle = makeStyles({
  root: {
    color: 'blue'
  },
  asterisk: {
    color: 'red'
  },
})

const FormLabel = ({ children }) => {
  const classes = useStyle()
  return (
    <MuiFormLabel
      classes={{
        root: classes.root,
        asterisk: classes.asterisk
      }}
    >
      {children}
    </MuiFormLabel>
  )
}
Run Code Online (Sandbox Code Playgroud)

我可以通过root并且asterisk使用样式化 API

我试过了,但没用

import React from 'react' …
Run Code Online (Sandbox Code Playgroud)

reactjs material-ui styled-components css-in-js

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

Hapi.js视图未加载CSS文件

我在使用和将app.css文件链接到default.html视图时遇到问题。我使用Cloud9进行托管。hapijshandlebars.js

这是我的应用程序结构:

root/
   client/
      config/
         route.js
      css/
         app.css
      view/
         layout/
            default.html
         index.html
server.js
Run Code Online (Sandbox Code Playgroud)

我的 server.js

'use strict';

const Hapi      = require('hapi');
const Vision    = require('vision');
const Inert     = require('inert');
const Path      = require('path');
const Routes    = require('./client/config/route')

const server = new Hapi.Server();

server.connection({
    host: process.env.IP || '0.0.0.0',
    port: process.env.PORT || 3000
});

server.register([Vision, Inert], (err) => {
    if (err) {
        throw err;
    }

    server.views({
        engines: {
            html: require('handlebars')
        },
        relativeTo: Path.join(__dirname, 'client'), …
Run Code Online (Sandbox Code Playgroud)

html javascript css handlebars.js hapijs

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