我使用fetch来调用post服务,我收到错误Fetch API cannot load http://localhost:8080/user/login.预检的响应无效(重定向)'.Status code: 302 Found.变量'data'是一个jsonobject {email: "batman@dc.com", password: "111"}
fetch('http://localhost:8080/user/login', {
method: 'post',
body : JSON.stringify(data),
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
dataType : 'json'
})
Run Code Online (Sandbox Code Playgroud) 是否有任何方法可以获取在执行任何事件/操作时呈现或重新呈现所有React组件的日志.我只想检查是否有任何不需要的React组件被重新渲染.我知道我们可以通过在render函数,componentWillReceiveProps或componentWillUpdate中添加控制台来实现这一点.但是我的webapp中有很多组件.在每个组件中添加控制台语句将是一团糟.有没有更好的办法?
在我编写测试用例的测试文件中,我导入了一个打字稿文件,如下所示:
import {rootReducer} from "../src/reducers/rootReducer";
Run Code Online (Sandbox Code Playgroud)
在rootReducer.ts中我导入了另一个打字稿文件,如下所示:
import taskReducer from "./taskReducer.ts";
Run Code Online (Sandbox Code Playgroud)
然后它显示错误:
SyntaxError: Unexpected reserved word
at src/reducers/rootReducer.ts:7
Run Code Online (Sandbox Code Playgroud)
rootReducer.ts和taskReducer.ts都位于文件夹/ src/reducers下
如果从import语句中删除".ts",但在浏览器中抛出错误,则没有失败的测试.该应用程序将无法运行
小袋鼠配置如下:
module.exports = function (wallaby) {
return {
files: [
'src/*.ts',
'src/**/*.ts'
],
tests: [
'test/*Test.ts'
],
testFramework: "mocha",
env: {
type: 'node'
},
compilers: {
'**/*.ts': wallaby.compilers.typeScript({
/* 1 for CommonJs*/
module: 1
})
}
}
};
Run Code Online (Sandbox Code Playgroud)