TS使用中的几个问题

问题1:
const {ccclass, property} = cc._decorator;
出错提示
[ts] Property ‘_decorator’ does not exist on type ‘typeof cc’.any

这个怎么弄?

问题2:
[ts]
Class ‘Test’ incorrectly extends base class ‘Component’.
Property ‘onLoad’ is protected in type ‘Test’ but public in type ‘Component’.

protected onLoad() 默认的方法,需要修改成 public onLoad()

这个是默认的问题,还是?

问题3:
在js中
node.getComponent(cc.Label).string = ‘xxx’;
但是在TS中,返回的是Component ,并没有string 属性。

这个是要强转吗?

问题4:
写好的TS在浏览器中可以,在模拟器中点了没反应。。。

请大神帮忙啊。。。。

  1. 这个应该是你没有正确的导入 creator.d.ts 吧?请参考
    http://www.cocos.com/docs/creator/getting-started/coding-setup.html#--1

  2. 抱歉这是默认脚本模板写错了,你把 protected 去掉即可,下个版本会修正

  3. 你现在先强转,下个版本更新完 creator.d.ts 后就会修正

  4. 模拟器黑屏的话,下个版本就会修正

好的,谢~:grinning: