12345678910111213141516171819202122232425262728293031323334353637383940 |
- /**
- * Toast单元格
- */
- cc.Class({
- extends: cc.Component,
- properties: {
- label: cc.RichText,
- msg: {
- multiline: true,
- type: cc.String,
- get () {
- return this._msg;
- },
- set (value) {
- if (this._msg !== value) {
- this._msg = value;
- this.updateMsg();
- }
- }
- },
- _msg: ''
- },
- /**
- * 更新 Toast 文本
- *
- * @author Pyden
- * @date 2019-03-22
- */
- updateMsg () {
- if (this.label) {
- this.label.string = this.msg;
- }
- this.node.width = this.label.node.width + 100; // 左右各50px边距
- this.node.height = this.label.node.height + 30; // 上下各15px边距
- }
- });
|