我在所有函数中都遇到错误,指出未定义道具。错误出现在以下功能的“ props”一词上
功能PostButton(道具) 函数PostButton2(props) 函数TotalVotes(props) 函数Post(props){ 函数CommentList(props)
我不想使用任何关键字来避免此警告。我这里的道具是什么?
答案 0 :(得分:0)
如果您正在使用打字稿,并且在{
"apiVersion": "2017-05-10",
"name": "[concat(parameters('virtualMachineName')[copyIndex()], '-' , 'BackupIntent')]",
"type": "Microsoft.Resources/deployments",
"resourceGroup": "[parameters('backupVaultRGName')]",
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"name": "[concat(parameters('backupVaultName'), '/', parameters('backupFabricName'), '/', parameters('backupItemName'))]",
"apiVersion": "2017-07-01",
"type": "Microsoft.RecoveryServices/vaults/backupFabrics/backupProtectionIntent",
"properties": {
"friendlyName": "[concat(parameters('virtualMachineName')[copyIndex()], 'BackupIntent')]",
"protectionIntentItemType": "AzureResourceItem",
"policyId": "[resourceId(parameters('backupVaultRGName'), 'Microsoft.RecoveryServices/vaults/backupPolicies', parameters('backupVaultName'), parameters('backupPolicyName'))]",
"sourceResourceId": "[resourceId(parameters('virtualMachineRG'), 'Microsoft.Compute/virtualMachines', parameters('virtualMachineName')[copyIndex()])]"
}
}
]
}
},
"copy": {
"name": "vmNICCopy",
"count": "[length(parameters('virtualMachineName'))]"
},
"dependsOn": [
"[resourceId(parameters('virtualMachineRG'), 'Microsoft.Compute/virtualMachines', [concat(parameters('virtualMachineName')[copyIndex())])]]"
]
}
中启用了严格的检查规则,则必须为所有道具定义类型。否则您必须禁用eslint
规则以不接受任何类型:
eslint
因此,您可以尝试使用这种方法来定义类型。然后,您可以继续使用interface Props {
handleclick: () =>,
text: string,
upvote: () =>,
}
变量,例如:
props