9

typescript怎么动态给object添加属性?

 3 years ago
source link: https://www.zhihu.com/question/465336030/answer/1943335002
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

typescript怎么动态给object添加属性?

登录后你可以
不限量看优质回答私信答主深度交流精彩内容一键收藏

和js中一样

继续浏览内容
发现更大的世界
Chrome
永远年轻的伪全栈码农

const a : Record<string, string> = {}
a.p1 = “hello”

enjoy!

继续浏览内容
v2-88158afcff1e7f4b8b00a1ba81171b61_720w.png
发现更大的世界
v2-a448b133c0201b59631ccfa93cb650f3_1440w.png
Chrome
more interest, less interests

ts是一个静态的类型检查系统,给对象添加属性,属于JS的范畴,JS如何添加属性,在TS中也是一样的。详细的TS的文章,可以关注我的CSDN,我有一个模块专门记录了自己在学习TS的笔记。https://blog.csdn.net/qq_41499782

继续浏览内容
v2-88158afcff1e7f4b8b00a1ba81171b61_720w.png
发现更大的世界
v2-a448b133c0201b59631ccfa93cb650f3_1440w.png
Chrome

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK