我按照官方给的提示在脚本中引用其他组件的脚本变量报错,不明所以啊,首先不要new一个出来,我要的是修改另一个脚本里的变量或者调用其中的函数。
const {ccclass, property} = cc._decorator;
@ccclass
export default class daoru extends cc.Component {
@property(cc.Label)
label: cc.Label = null;
@property
text: string = 'hello';
// LIFE-CYCLE CALLBACKS:
// onLoad () {}
start () {
}
// update (dt) {}
}
//helloworld.ts
const {ccclass, property} = cc._decorator;
import daoru from “./daoru”;
@ccclass
export default class Helloworld extends cc.Component {
@property(cc.Label)
label: cc.Label = null;
@property
text: string = 'hello';
@property(daoru)
public my:daoru=null;
public start () {
// init logic
this.label.string = this.text;
console.log("ceshi:"+this.my.text);
}
}
这是错误提示:
Simulator: E/jswrapper (271): ERROR: Uncaught TypeError: Cannot read property ‘text’ of null, location: assets/Script/Helloworld.js:0:0


