关于typescript中接口的问题
本文介绍了关于typescript中接口的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
function createSquare(config: SquareConfig): {color: string; area: number} {
let newSquare = {color: "white", area: 100};
if (config.color) {
newSquare.color = config.color;
}
if (config.width) {
newSquare.area = config.width * config.width;
}
return newSquare;
}
函数后边{color: string; area: number} 这个是什么意思,貌似不写这个也不会有问题。
不知道这个到底其什么作用?求教了
解决方案
指的是对函数返回值的要求
这篇关于关于typescript中接口的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文