mirror of https://github.com/layui/layui
修复非安全域复制失败问题
parent
5bf9cdc72b
commit
ae8dede13d
|
@ -112,9 +112,17 @@ layui.define(['lay', 'util', 'element', 'form'], function(exports){
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
layer.msg('复制失败', {
|
var text = document.createElement("textarea");
|
||||||
icon: 2
|
text.setAttribute("readonly", "readonly");
|
||||||
});
|
text.value = util.unescape(finalCode);
|
||||||
|
document.body.appendChild(text);
|
||||||
|
text.select();
|
||||||
|
if (document.execCommand("copy")){
|
||||||
|
layer.msg('已复制', {icon: 1});
|
||||||
|
}else {
|
||||||
|
layer.msg('复制失败', {icon: 2});
|
||||||
|
}
|
||||||
|
document.body.removeChild(text);
|
||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
}
|
}
|
||||||
|
@ -369,4 +377,4 @@ layui.define(['lay', 'util', 'element', 'form'], function(exports){
|
||||||
// 若为源码版,则自动加载该组件依赖的 css 文件
|
// 若为源码版,则自动加载该组件依赖的 css 文件
|
||||||
if(!layui['layui.all']){
|
if(!layui['layui.all']){
|
||||||
layui.addcss('modules/code.css?v=3', 'skincodecss');
|
layui.addcss('modules/code.css?v=3', 'skincodecss');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue