剪贴板
接口声明
{ "name": "system.clipboard" }
导入模块
import clipboard from '@system.clipboard' 或 const clipboard = require('@system.clipboard')
接口定义
clipboard.set(OBJECT)
修改剪贴板内容
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
text | String | 是 | 需要放到剪切板的内容 |
success | Function | 否 | 成功回调 |
fail | Function | 否 | 失败回调 |
complete | Function | 否 | 执行结束后的回调 |
示例:
clipboard.set({
text: 'text'
})
clipboard.get(OBJECT)
读取剪贴板内容
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
success | Function | 否 | 成功回调 |
fail | Function | 否 | 失败回调 |
complete | Function | 否 | 执行结束后的回调 |
success 返回值:
参数名 | 类型 | 说明 |
---|---|---|
text | String | 剪切板内容 |
示例:
clipboard.get({
success: function(data) {
console.log(`handling success: ${data.text}`)
},
fail: function(data, code) {
console.log(`handling fail, code = ${code}`)
}
})
后台运行限制
禁止使用。后台运行详细用法参见后台运行 脚本。