小编Lê *_*ánh的帖子

找不到模块“module.css”或其相应的类型声明

不知道为什么打字稿突然无法识别我的代码,它显示

Cannot find module './hookStyle/useMemostyle.module.css' or its corresponding type declarations
Run Code Online (Sandbox Code Playgroud)

当我将样式移动到另一个文件夹时会发生这种情况

这是打字稿配置

{
  "compilerOptions": {
    "lib": [
      "ESNext",
      "dom"
    ],
    "outDir": "lib",
    "removeComments": true,
    "target": "ES6",
    "baseUrl": "src",
    "esModuleInterop": true,
    "moduleResolution": "node",
    "sourceMap": true,
    "sourceRoot": "/",
    "alwaysStrict": true,
    "allowUnreachableCode": false,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "noImplicitReturns": true,
    "noUncheckedIndexedAccess": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "allowJs": true,
    "skipLibCheck": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "module": "esnext",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx"
  },
  "include": [
    "./**/*.ts"
  ],
  "exclude": …
Run Code Online (Sandbox Code Playgroud)

javascript typescript

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

为什么 1<x<3 总是正确的?

我正在学习 TypeScript,在入门页面中,他们谈论了 javascript 是多么出人意料。

来源https://www.typescriptlang.org/docs/handbook/typescript-from-scratch.html

if ("" == 0) {
// It is! But why??
}
if (1 < x < 3) {
// True for *any* value of x!
}
Run Code Online (Sandbox Code Playgroud)

但我还是不明白为什么1<x<3总是这样?例如,如果我让 x=10,从逻辑上讲它不会为真,但为什么他们说它总是为真?

javascript typescript

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

mobX:类型错误:无法读取未定义的属性

我只是用 mobX 玩了一些代码,就发生了这种情况,不知道为什么,但我确信它与官方文档没有太大不同

这是store.tsx

import { observable, computed, action, makeObservable, override, makeAutoObservable } from "mobx"

class CounterStore {
  initValue = 0
  powValue = Math.pow(this.initValue, 2)
  constructor() {
    makeAutoObservable(this)
  }
  increaseNumber() {
    this.initValue = this.initValue + 1
  }
}
const Store = new CounterStore()
export default Store
Run Code Online (Sandbox Code Playgroud)

这是我使用这个的地方。称为增量.tsx

import { observer } from "mobx-react"

export const IncrementButton = observer(({ store }) => {
  return (
    <div>
      <button onClick={store.increaseNumber}>Increase</button>
      <h1>{store.initValue}</h1>
    </div>
  )
})
Run Code Online (Sandbox Code Playgroud)

index.tsx

ReactDOM.render(
  <React.StrictMode>
    <IncrementButton store={Store} /> …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs mobx

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

标签 统计

javascript ×3

typescript ×2

mobx ×1

reactjs ×1