我有一个使用npx create-react-app --template typescript. 当我运行时npm start,我的一个文件中出现错误:
TypeScript error in /<path>/App.tsx:
Cannot find module 'moment'. TS2307
Run Code Online (Sandbox Code Playgroud)
进口:
import moment from 'moment'
Run Code Online (Sandbox Code Playgroud)
配置文件
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react",
"noImplicitAny": false,
"experimentalDecorators": true
},
"include": ["src", "husky.config.js", "lint-staged.config.js"]
}
Run Code Online (Sandbox Code Playgroud)
使用"moment": "^2.25.0"在package.json。使用 npm。
查看node_modules目录,我可以看到moment包, …
我在测试 go-chi 路线时遇到问题,特别是带有路径变量的路线。运行服务器go run main.go工作正常,并且使用路径变量请求路由的行为符合预期。
当我运行路由测试时,我总是收到 HTTP 错误:Unprocessable Entity。注销发生的情况后articleID,似乎articleCtx无法访问路径变量。不确定这是否意味着我需要articleCtx在测试中使用,但我已经尝试ArticleCtx(http.HandlerFunc(GetArticleID))并收到错误:
panic: interface conversion: interface {} is nil, not *chi.Context [recovered]
panic: interface conversion: interface {} is nil, not *chi.Context
运行服务器:go run main.go
测试服务器:go test .
我的来源:
// main.go
package main
import (
"context"
"fmt"
"net/http"
"strconv"
"github.com/go-chi/chi"
)
type ctxKey struct {
name string
}
func main() {
r := chi.NewRouter()
r.Route("/articles", func(r chi.Router) {
r.Route("/{articleID}", func(r …Run Code Online (Sandbox Code Playgroud) 为什么要在香草MobX上使用MobX状态树?好像我每次阅读有关MobX的文章时,都在同一个地方提到了MST。有人真的只在使用MobX吗?
问题可能太笼统了...