【转载】QML中嵌入的JS方法

转载自Qt官方手册:List of JavaScript Objects and Functions


JavaScript对象和函数参考手册


1. 全局对象 (The Global Object)

1.1 值属性 (Value Properties)

  • NaN 非数字值
  • Infinity 无穷大
  • undefined 未定义

1.2 函数属性 (Function Properties)

  • eval(x) 执行字符串代码
  • parseInt(string, radix) 字符串转整数
  • parseFloat(string) 字符串转浮点数
  • isNaN(number) 检查是否为NaN
  • isFinite(number) 检查是否为有限数
  • decodeURI(encodedURI) 解码URI
  • decodeURIComponent(encodedURIComponent) 解码URI组件
  • encodeURI(uri) 编码URI
  • encodeURIComponent(uriComponent) 编码URI组件
  • escape(string) 编码字符串
  • unescape(string) 解码字符串

1.3 构造函数属性 (Constructor Properties)

  • Object 对象构造函数
  • Function 函数构造函数
  • Array 数组构造函数
  • ArrayBuffer 数组缓冲区
  • String 字符串构造函数
  • Boolean 布尔值构造函数
  • Number 数字构造函数
  • DataView 数据视图
  • Date 日期构造函数
  • Promise Promise对象
  • RegExp 正则表达式
  • Map Map对象
  • WeakMap 弱引用Map
  • Set Set对象
  • WeakSet 弱引用Set
  • SharedArrayBuffer 共享数组缓冲区
  • Symbol Symbol对象
  • Error 错误对象
  • EvalError eval错误
  • RangeError 范围错误
  • ReferenceError 引用错误
  • SyntaxError 语法错误
  • TypeError 类型错误
  • URIError URI错误

1.4 其他属性 (Other Properties)

  • Atomics 原子操作
  • Math 数学对象
  • JSON JSON对象
  • Reflect 反射对象
  • Proxy 代理对象


2. Object对象 (The Object Object)

2.1 Object构造函数 (Object Constructor)

函数属性 (Function Properties)

  • getPrototypeOf(O) 获取原型
  • setPrototypeOf(O, P) 设置原型
  • getOwnPropertyDescriptor(O, P) 获取属性描述符
  • getOwnPropertyDescriptors(O) 获取所有属性描述符
  • getOwnPropertyNames(O) 获取所有属性名
  • getOwnPropertySymbols(O) 获取所有Symbol属性
  • assign(O [, Properties]) 合并对象
  • create(O [, Properties]) 创建对象
  • defineProperty(O, P, Attributes) 定义属性
  • defineProperties(O, Properties) 定义多个属性
  • entries(O) 获取键值对数组
  • is(V1, V2) 比较值是否相同
  • keys(O) 获取可枚举属性名
  • values(O) 获取可枚举属性值
  • seal(O) 密封对象
  • isSealed(O) 检查是否密封
  • freeze(O) 冻结对象
  • isFrozen(O) 检查是否冻结
  • preventExtensions(O) 阻止扩展
  • isExtensible(O) 检查是否可扩展

2.2 Object原型 (Object Prototype)

函数属性 (Function Properties)

  • toString() 转为字符串
  • toLocaleString() 本地化字符串
  • valueOf() 获取原始值
  • hasOwnProperty(V) 检查是否自有属性
  • isPrototypeOf(V) 检查是否在原型链上
  • propertyIsEnumerable(V) 检查是否可枚举
  • __defineGetter__(P, F) 定义getter
  • __defineSetter__(P, F) 定义setter


3. 函数对象 (Function Objects)

3.1 函数原型 (Function Prototype)

函数属性 (Function Properties)

  • toString() 转为字符串
  • apply(thisArg, argArray) 调用函数
  • call(thisArg [, arg1 [, arg2, ...]]) 调用函数
  • bind((thisArg [, arg1 [, arg2, …]]) 绑定this
  • [Symbol.hasInstance](O) instanceof操作符调用


4. 数组对象 (Array Objects)

4.1 数组原型对象 (Array Prototype Object)

函数属性 (Function Properties)

  • toString() 转为字符串
  • toLocaleString() 本地化字符串
  • concat([item1 [, item2 [, ...]]]) 合并数组
  • copyWithin([item1 [, item2 [, ...]]]) 数组内复制
  • entries() 返回键值对迭代器
  • fill(item [, index1 [, index2]]) 填充数组
  • join(separator) 连接数组元素
  • find(callbackfn [, thisArg]) 查找元素
  • findIndex(callbackfn [, thisArg]) 查找元素索引
  • includes(item) 检查是否包含
  • keys() 返回键迭代器
  • pop() 移除最后一个元素
  • push([item1 [, item2 [, ...]]]) 添加元素到末尾
  • reverse() 反转数组
  • shift() 移除第一个元素
  • slice(start, end) 截取数组
  • sort(comparefn) 排序数组
  • splice(start, deleteCount[, item1 [, item2 [, ...]]]) 修改数组
  • unshift([item1 [, item2 [, ...]]]) 添加元素到开头
  • indexOf(searchElement [, fromIndex]) 查找元素索引
  • lastIndexOf(searchElement [, fromIndex]) 从后查找元素索引
  • every(callbackfn [, thisArg]) 测试所有元素
  • some(callbackfn [, thisArg]) 测试某些元素
  • forEach(callbackfn [, thisArg]) 遍历数组
  • map(callbackfn [, thisArg]) 映射数组
  • filter(callbackfn [, thisArg]) 过滤数组
  • reduce(callbackfn [, initialValue]) 从左累加
  • reduceRight(callbackfn [, initialValue]) 从右累加
  • values() 返回值迭代器
  • [Symbol.iterator]() 返回迭代器


5. 字符串对象 (String Objects)

5.1 字符串原型对象 (String Prototype Object)

函数属性 (Function Properties)

  • toString() 转为字符串
  • valueOf() 获取原始值
  • charAt(pos) 获取指定位置字符
  • charCodeAt(pos) 获取字符编码
  • codePointAt(pos) 获取代码点
  • concat([string1 [, string2 [, ...]]]) 连接字符串
  • endsWith(searchString [, endPosition ]) 检查是否以某字符串结尾
  • includes(searchString [, position ]) 检查是否包含
  • indexOf(searchString ,position) 查找字符串位置
  • lastIndexOf(searchString, position) 从后查找字符串位置
  • localeCompare(that) 本地化比较
  • match(regexp) 匹配正则
  • normalize() Unicode标准化
  • padEnd(length [, string]) 尾部填充
  • padStart(length [, string]) 头部填充
  • repeat(count) 重复字符串
  • replace(searchValue, replaceValue) 替换字符串
  • search(regexp) 搜索正则匹配
  • slice(start, end) 截取字符串
  • split(separator, limit) 分割字符串
  • startsWith(searchString [, position ]) 检查是否以某字符串开头
  • substr(start, length) 截取子串
  • substring(start, end) 截取子串
  • toLowerCase() 转为小写
  • toLocaleLowerCase() 本地化转为小写
  • toUpperCase() 转为大写
  • toLocaleUpperCase() 本地化转为大写
  • trim() 去除两端空白
  • [Symbol.iterator]() 返回迭代器

QML引擎添加的函数

  • string::arg() 格式化字符串


6. 布尔对象 (Boolean Objects)

6.1 布尔原型对象 (Boolean Prototype Object)

函数属性 (Function Properties)

  • toString() 转为字符串
  • valueOf() 获取原始值


7. 数字对象 (Number Objects)

7.1 数字原型对象 (Number Prototype Object)

函数属性 (Function Properties)

  • toString(radix) 转为指定进制字符串
  • toLocaleString() 本地化字符串
  • valueOf() 获取原始值
  • toFixed(fractionDigits) 转为固定小数位字符串
  • toExponential(fractionDigits) 转为指数形式
  • toPrecision(precision) 转为指定精度字符串

QML引擎添加的函数

  • fromLocaleString(locale, number) 从本地化字符串解析
  • toLocaleCurrencyString(locale, symbol) 转为本地化货币字符串
  • toLocaleString(locale, format, precision) 转为本地化字符串

7.2 Number对象 (The Number Object)

值属性 (Value Properties)

  • NaN 非数字值
  • NEGATIVE_INFINITY 负无穷
  • POSITIVE_INFINITY 正无穷
  • MAX_VALUE 最大数值
  • MIN_VALUE 最小数值
  • EPSILON 极小常量
  • MAX_SAFE_INTEGER 最大安全整数
  • MIN_SAFE_INTEGER 最小安全整数

函数属性 (Function Properties)

  • isFinite(x) 检查是否有限
  • isInteger(x) 检查是否为整数
  • isSafeInteger(x) 检查是否为安全整数
  • isNaN(x) 检查是否为NaN


8. 数学对象 (The Math Object)

8.1 值属性 (Value Properties)

  • E 自然对数底
  • LN10 10的自然对数
  • LN2 2的自然对数
  • LOG2E 以2为底E的对数
  • LOG10E 以10为底E的对数
  • PI 圆周率
  • SQRT1_2 1/2的平方根
  • SQRT2 2的平方根

8.2 函数属性 (Function Properties)

  • abs(x) 绝对值
  • acos(x) 反余弦
  • acosh(x) 反双曲余弦
  • asin(x) 反正弦
  • asinh(x) 反双曲正弦
  • atan(x) 反正切
  • atanh(x) 反双曲正切
  • atan2(y, x) 两点间角度
  • cbrt(x) 立方根
  • ceil(x) 向上取整
  • clz32(x) 前导零位数
  • cos(x) 余弦
  • cosh(x) 双曲余弦
  • exp(x) e的x次方
  • expm1(x) e^x-1
  • floor(x) 向下取整
  • fround(x) 最近单精度浮点
  • hypot(x, y) 平方和的平方根
  • imul(x, y) 32位整数乘法
  • log(x) 自然对数
  • log10(x) 以10为底对数
  • log1p(x) 1+x的自然对数
  • log2(x) 以2为底对数
  • max([value1 [, value2 [, ...]]]) 最大值
  • min([value1 [, value2 [, ...]]]) 最小值
  • pow(x, y) x的y次方
  • random() 随机数
  • round(x) 四舍五入
  • sign(x) 符号函数
  • sin(x) 正弦
  • sinh(x) 双曲正弦
  • sqrt(x) 平方根
  • tan(x) 正切
  • tanh(x) 双曲正切
  • trunc(x) 去除小数部分


9. 日期对象 (Date Objects)

9.1 日期原型对象 (Date Prototype Object)

函数属性 (Function Properties)

  • toString() 转为字符串
  • toDateString() 返回日期部分字符串
  • toTimeString() 返回时间部分字符串
  • toLocaleString() 本地化字符串
  • toLocaleDateString() 本地化日期字符串
  • toLocaleTimeString() 本地化时间字符串
  • valueOf() 获取原始值
  • getTime() 获取时间戳
  • getFullYear() 获取年份
  • getUTCFullYear() 获取UTC年份
  • getMonth() 获取月份
  • getUTCMonth() 获取UTC月份
  • getDate() 获取日期
  • getUTCDate() 获取UTC日期
  • getDay() 获取星期
  • getUTCDay() 获取UTC星期
  • getHours() 获取小时
  • getUTCHours() 获取UTC小时
  • getMinutes() 获取分钟
  • getUTCMinutes() 获取UTC分钟
  • getSeconds() 获取秒数
  • getUTCSeconds() 获取UTC秒数
  • getMilliseconds() 获取毫秒
  • getUTCMilliseconds() 获取UTC毫秒
  • getTimeZoneOffset() 获取时区偏移
  • setTime(time) 设置时间戳
  • setMilliseconds(ms) 设置毫秒
  • setUTCMilliseconds(ms) 设置UTC毫秒
  • setSeconds(sec [, ms]) 设置秒
  • setUTCSeconds(sec [, ms]) 设置UTC秒
  • setMinutes(min [, sec [, ms]]) 设置分钟
  • setUTCMinutes(min [, sec [, ms]]) 设置UTC分钟
  • setHours(hour [, min [, sec [, ms]]]) 设置小时
  • setUTCHours(hour [, min [, sec [, ms]]]) 设置UTC小时
  • setDate(date) 设置日期
  • setUTCDate(date) 设置UTC日期
  • setMonth(month [, date]) 设置月份
  • setUTCMonth(month [, date]) 设置UTC月份
  • setYear(year) 设置年份
  • setFullYear(year [, month [, date]]) 设置完整年份
  • setUTCFullYear(year [, month [, date]]) 设置UTC完整年份
  • toUTCString() 转为UTC字符串
  • toGMTString() 转为GMT字符串
  • toISOString() 转为ISO格式字符串
  • toJSON() 转为JSON字符串
  • [Symbol.toPrimitive](hint) 原始值转换

QML引擎添加的函数

  • timeZoneUpdated() 时区更新
  • toLocaleDateString(locale, format) 本地化日期字符串
  • toLocaleString(locale, format) 本地化字符串
  • toLocaleTimeString(locale, format) 本地化时间字符串


10. 正则表达式对象 (RegExp Objects)

10.1 正则表达式原型对象 (RegExp Prototype Object)

函数属性 (Function Properties)

  • exec(string) 执行匹配
  • test(string) 测试匹配
  • toString() 转为字符串


11. 错误对象 (Error Objects)

11.1 错误原型对象 (Error Prototype Object)

值属性 (Value Properties)

  • name 错误名称
  • message 错误消息

函数属性 (Function Properties)

  • toString() 转为字符串


12. JSON对象 (The JSON Object)

函数属性 (Function Properties)

  • parse(text [, reviver]) 解析JSON字符串
  • stringify(value [, replacer [, space]]) 转为JSON字符串
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇