refine toString API intro (#3225)

This commit is contained in:
Jare Guo
2018-09-11 16:00:57 +08:00
committed by pandamicro
parent b90fbe9233
commit 4a7d2e93e4
2 changed files with 13 additions and 2 deletions
+5 -2
View File
@@ -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}
*/
+8
View File
@@ -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;
}