根据Dan Abramov 的推文,CSS模块支持在create-react-app(CRA)中.只需要扩展module.css他的样式表来启用该功能,但这不适用于我.我的版本是1.1.4 react-scripts.如何使用CRA启用css模块?谢谢
假设我在firestore数据库中有这个结构:
collection[
document: {
x: 'x',
y: 'y'
}
]Run Code Online (Sandbox Code Playgroud)
我有这个firebase规则:
service cloud.firestore {
match /databases/{database}/documents {
match /collection/{document} {
allow read: if true;
}
}
}Run Code Online (Sandbox Code Playgroud)
但是这个规则暴露了document上面的整体collection,我想要做的只是暴露x场,是否可能?谢谢
我正在使用 axios 发出 HTTP 请求并收到错误。这是axios 文档中有关错误处理的片段。
axios.get('/user/12345')
.catch(function (error) {
if (error.response) {
// The request was made and the server responded with a status code
// that falls out of the range of 2xx
console.log(error.response.data);
console.log(error.response.status);
console.log(error.response.headers);
} else if (error.request) {
// The request was made but no response was received
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
// http.ClientRequest in node.js
console.log(error.request);
} else {
// Something happened …Run Code Online (Sandbox Code Playgroud)看看这个示例打字稿代码
function printLabel(labelledObj: { label: string }) {
console.log(labelledObj.label);
}
printLabel({ size: 10, label: 'hello' });
Run Code Online (Sandbox Code Playgroud)
上面的代码无法编译,并出现以下错误:
1.ts:6:14-错误TS2345:参数'{size:number; 标签:字符串;}'不可分配给类型'{label:string; }'。对象文字只能指定已知的属性,并且'size'在类型'{label:string; }'。
简而言之,size是一个多余的属性,不符合{ label: string }导致编译器大喊大叫的类型。让我们稍微修改一下上面的代码片段:
function printLabel(labelledObj: { label: string }) {
console.log(labelledObj.label);
}
const obj = { size: 10, label: 'hello' }
printLabel(obj);
Run Code Online (Sandbox Code Playgroud)
现在我们将对象字面量提取出来,该字面量已printLabel在较早的示例中传递到名为的中间引用中obj,最奇怪的部分是它现在不会抱怨并且可以正常工作。为什么打字稿表现得如此?