creator中的装饰器怎么用?

请问cocos creator中的装饰器怎么用?
我参照http://www.cocos.com/docs/creator/api/modules/_decorator.html
中的内容,然后在cocos creator中新建了一个Hello World项目,然后将原来的HelloWorld.js从:

cc.Class({
    extends: cc.Component,

    properties: {
        label: {
            default: null,
            type: cc.Label
        },
        // defaults, set visually when attaching this script to the Canvas
        text: 'Hello, World!'
    },

    // use this for initialization
    onLoad: function () {
        this.label.string = this.text;
    },

    // called every frame
    update: function (dt) {

    },
});

改成了下面这样子:

const {ccclass} = cc._decorator;

@ccclass
class HelloWorld extends ccclass.Component {

    @property(cc.Label)
    label = null;

    @property
    text = "Hello, World!";

    // use this for initialization
    onLoad: function () {
        this.label.string = this.text;
    },

    // called every frame
    update: function (dt) {

    },
}

然后就报错了,请问是应该怎么用的?

应该是你没有导入property所以报错了。

应该是:

const {ccclass, property} = cc._decorator;

你可以直接在Creator中新建一个TypeScript脚本看一下默认写法。