当我尝试在用作依赖项的模块中使用 React Hooks 时,它失败了。我收到以下错误:
Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
Run Code Online (Sandbox Code Playgroud)
但如果我使用基于类的组件,那就没问题了。为什么会发生这种情况?
这是我的摘录package.json
{
"main": "dist/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "./node_modules/.bin/babel src -d dist",
"prepublish": "npm run build"
},
"peerDependencies": {
"react": "^16.10.2",
"react-router-dom": "^5.1.2"
},
"devDependencies": {
"axios": "^0.19.0",
"jwt-decode": "^2.2.0",
"qs": "^6.9.0",
"@babel/cli": "^7.6.4",
"@babel/core": "^7.6.4",
"@babel/preset-env": "^7.6.3",
"@babel/preset-react": "^7.6.3"
} …Run Code Online (Sandbox Code Playgroud) 任何 VS Code 扩展来突出显示重复的 css 属性?例如
.test {
font-size: 14px;
...
font-size: 10px;
}
Run Code Online (Sandbox Code Playgroud) 例如:片段 img
var a = {1: '1', 2: '2'}
var b = {3: '3', 4: '4'}
Object.assign({}, a, b)
> {1: "1", 2: "2", 3: "3", 4: "4"}
Object.assign({}, b, a)
> {1: "1", 2: "2", 3: "3", 4: "4"}
Run Code Online (Sandbox Code Playgroud)
有没有办法禁用排序?
是否可以使用全局 onRequest 处理程序通过 Nuxt3 进行 $fetch,以在每个请求上添加特定数据?使用 nuxt2 和 axios 就很简单
/plugins/axios.js
export default function ({ $axios, store, req }) {
$axios.onRequest((config) => {
if (config.data) {
config.data.test = '123';
} else {
config.data = { test: '123' };
}
return config;
});
}
Run Code Online (Sandbox Code Playgroud)
但是如何在 Nuxt3 和 $fetch 上实现相同的目标呢?
css ×1
ecmascript-5 ×1
ecmascript-6 ×1
fetch ×1
javascript ×1
npm ×1
npm-publish ×1
nuxt.js ×1
nuxt3 ×1
react-hooks ×1
reactjs ×1
vue.js ×1