在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
一、The key 'Accept' is not sorted alphabetically //tslint.json { "extends": ["tslint:recommended", "tslint-react", "tslint-config-prettier"], "rules": { "object-literal-sort-keys": false //Disable for typescript }, "jsRules": { "object-literal-sort-keys": false //Disable for javascript } } 二、内置对象的数据类型声明 点击链接:链接 三、event对象的数据类型声明 四、接收子组件的传值绑定方法 //示例 //添加taskList public addTaskHandle = (newItem: Itasks)=>{ let allTask: Itasks[] = this.state.list let newArray: Itasks[] = allTask newArray.push(newItem) this.setState({ list: newArray, totallist: newArray }) } 五、Lambdas are forbidden in JSX attributes due to their rendering performance im **** //tslint.json "rules": { "jsx-no-lambda": false, } 六、无法console //tslint.json "rules": { "no-console": [false, "log", "error"], } 七、for (... in ...) statements must be filtered with an if statement // 示例 //error:for (... in ...) statements must be filtered with an if statement for (const key in Object.keys(obj)) { result += '&' + key + '=' + encodeURIComponent(obj[key]) } // true for (const key in Object.keys(obj)) { if (obj.hasOwnProperty(key)) {//需要添加原型判断 result += '&' + key + '=' + encodeURIComponent(obj[key]) } } // tslint.json
"rules": {
"forin": true,
}
注:tslint.json 常见配置 链接 typescript官网:链接 |
请发表评论