mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-06 19:42:39 +08:00
refine toString API intro (#3225)
This commit is contained in:
@@ -163,12 +163,15 @@ export default class Asset extends RawAsset {
|
||||
static preventPreloadNativeObject = false;
|
||||
|
||||
/**
|
||||
* Returns the asset's url.
|
||||
* Returns the string representation of the object.
|
||||
*
|
||||
* The `Asset` object overrides the `toString()` method of the `Object` object.
|
||||
* For `Asset` objects, the toString() method returns a string representation of the object.
|
||||
* JavaScript calls the toString() method automatically when an asset is to be represented as a text value or when a texture is referred to in a string concatenation.
|
||||
*
|
||||
* For assets of the native type, it will return `this.nativeUrl`.
|
||||
* Otherwise, an empty string is returned.
|
||||
* This method may be overwritten by subclasses.
|
||||
*
|
||||
* @method toString
|
||||
* @return {String}
|
||||
*/
|
||||
|
||||
@@ -44,6 +44,14 @@ export default class TextAsset extends Asset {
|
||||
@property()
|
||||
text = "";
|
||||
|
||||
/**
|
||||
* Returns the text content of the asset.
|
||||
*
|
||||
* JavaScript calls the toString() method automatically when an asset is to be represented as a text value or when a texture is referred to in a string concatenation.
|
||||
*
|
||||
* @method toString
|
||||
* @return {String}
|
||||
*/
|
||||
toString () {
|
||||
return this.text;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user