读写剪切板 系统 剪切板 navigator.clipboard.writeText(inputVal)
https://developers.weixin.qq.com/miniprogram/dev/api/clipboard.html#wxsetclipboarddataobject
ClipboardEvent.clipboardData - Web API 接口参考 | MDN https://developer.mozilla.org/zh-CN/docs/Web/API/ClipboardEvent/clipboardData
<body>
<input type="text" id="myInput">
</body>
<script>
const target = document.getElementById('myInput');
target.addEventListener('input', (event) => {
let inputVal = target.value;
navigator.clipboard.writeText(inputVal);
});
</script>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<link
href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.6.1/css/bootstrap.min.css"
rel="stylesheet"
/>
<body>
<div class="container">
<div style="padding: 100px 100px 10px">
<form class="bs-example bs-example-form" role="form">
<div class="input-group">
<input
type="text"
class="form-control"
placeholder="code"
id="myInput"
/>
</div>
</form>
</div>
<h2 id="myShow" style="text-align: center"></h2>
</div>
</body>
<script>
const al = [
"a1ā",
"a2á",
"a3ǎ",
"a4à",
"o1ō",
"o2ó",
"o3ǒ",
"o4ò",
"e1ē",
"e2é",
"e3ě",
"e4è",
"i1ī",
"i2í",
"i3ǐ",
"i4ì",
"u1ū",
"u2ú",
"u3ǔ",
"u4ù",
"v1ǖ",
"v2ǘ",
"v3ǚ",
"v4ǜ",
"n1ṉ",
"n2ń",
"n3ň",
"n4ǹ",
"g1ḡ",
"g2ǵ",
"g3ǧ",
"g4ġ",
"r1ṙ",
"r2ŕ",
"r3ř",
"r4ṟ",
];
const len = al.length;
const target = document.getElementById("myInput");
const myShow = document.getElementById("myShow");
target.addEventListener("input", (event) => {
let inputVal = target.value;
// navigator.clipboard.writeText(inputVal);
let c = [];
for (i = 0; i < len; i++) {
let v = al[i];
if (v.indexOf(inputVal) > -1) {
c.push(v.replace(inputVal, ""));
}
}
const ret=c.join('<br>');
navigator.clipboard.writeText(ret);
myShow.innerHTML = ret;
});
</script>
</html>