微信小程序WXS語法的基礎類庫有哪些?小編整理分享給大家:
console
console.log 方法用于在 console 窗口輸出信息。它可以接受多個參數,將它們的結果連接起來輸出。
Math
屬性
E
LN10
LN2
LOG2E
LOG10E
PI
SQRT1_2
SQRT2
以上屬性的具體使用請參考 ES5 標準。
方法
abs
acos
asin
atan
atan2
ceil
cos
exp
floor
log
max
min
pow
random
round
sin
sqrt
tan
以上方法的具體使用請參考 ES5 標準。
JSON
方法
stringify(object): 將 object 對象轉換為 JSON 字符串,并返回該字符串。
parse(string): 將 JSON 字符串轉化成對象,并返回該對象。
示例代碼:
console.log(undefined === JSON.stringify());
console.log(undefined === JSON.stringify(undefined));
console.log(“null”===JSON.stringify(null));
console.log(“111″===JSON.stringify(111));
console.log(‘”111″‘===JSON.stringify(“111”));
console.log(“true”===JSON.stringify(true));
console.log(undefined===JSON.stringify(function(){}));
console.log(undefined===JSON.parse(JSON.stringify()));
console.log(undefined===JSON.parse(JSON.stringify(undefined)));
console.log(null===JSON.parse(JSON.stringify(null)));
console.log(111===JSON.parse(JSON.stringify(111)));
console.log(“111″===JSON.parse(JSON.stringify(“111”)));
console.log(true===JSON.parse(JSON.stringify(true)));
console.log(undefined===JSON.parse(JSON.stringify(function(){})));
Number
屬性
MAX_VALUE
MIN_VALUE
NEGATIVE_INFINITY
POSITIVE_INFINITY
以上屬性的具體使用請參考 ES5 標準。
Date
屬性
parse
UTC
now
以上屬性的具體使用請參考 ES5 標準。
Global
屬性
NaN
Infinity
undefined
以上屬性的具體使用請參考 ES5 標準。
方法
parseInt
parseFloat
isNaN
isFinite
decodeURI
decodeURIComponent
encodeURI
encodeURIComponent
以上方法的具體使用請參考 ES5 標準。