Files
todo-frontend/node_modules/licia/copy.js
Agent d12eea7693
Some checks failed
continuous-integration/drone/push Build is failing
fix: 微信登录补充保存username和role
2026-04-04 07:35:21 +00:00

32 lines
691 B
JavaScript

var extend = require('./extend');
var noop = require('./noop');
exports = function(text, cb) {
cb = cb || noop;
var el = document.createElement('textarea');
var body = document.body;
extend(el.style, {
fontSize: '12pt',
border: '0',
padding: '0',
margin: '0',
position: 'absolute',
left: '-9999px'
});
el.value = text;
body.appendChild(el);
el.setAttribute('readonly', '');
el.select();
el.setSelectionRange(0, text.length);
try {
document.execCommand('copy');
cb();
} catch (e) {
cb(e);
} finally {
body.removeChild(el);
}
};
module.exports = exports;