我正在设置 admin 休息,现在我在尝试获取数据时收到此错误,即使我从服务器收到了所有需要的数据:
The Content-Range header is missing in the HTTP Response. The simple REST client expects responses for lists of resources to contain this header with the total number of results to build the pagination. If you are using CORS, did you declare Content-Range in the Access-Control-Expose-Headers header?
Run Code Online (Sandbox Code Playgroud)
有没有办法在不更改 API 的情况下解决它?我正在根据教程进行授权,这是我的 app.js:
if (!options.headers) {
options.headers = new Headers({ Accept: 'application/json' });
}
const token = localStorage.getItem('token');
options.headers.set('Authorization', `Bearer ${"token"}`);
return fetchUtils.fetchJson(url, options);
}
const restClient = simpleRestClient('https://mywebsite.com', httpClient); …Run Code Online (Sandbox Code Playgroud) 我的应用程序根据用户名是小写还是大写来验证用户名。这是我目前拥有的验证:format: { with: /\A[a-zA-Z0-9]+\Z/ }但是,如果我这样做:format: { with: /\A[a-z0-9]+\z/ },当用户输入大写字母时,即使没有使用用户名,它也会说用户名无效。如何使用户名小写并验证它是否存在,使用户能够输入大写字母而不显示username is invalid?
我正在尝试从子级调用父类的函数以关闭模式。但是,我总是undefined is not an object this.ref.modal
这就是我所拥有的:
1st
Import Two from ‘./Two’;
export default class One extends Component {
static closeModal(){
this.refs.modal.close();
}
<Modal>
</Two>
</Modal>
}
2nd
Import One from ‘./One’;
export default class Two extends Component {
randomFunction(){
One.CloseModal();
}
}
Run Code Online (Sandbox Code Playgroud)
第一个组件是模式框,第二个组件是Camera。我想从Camera组件关闭第一个模态。难道我做错了什么?