對于這個非常基本的問題,我很抱歉,但我找不到。基本上我試圖逐行讀取這個檔案,然后在另一個 HTML 頁面中,只要有一個字串與其中一行匹配,那么它將被包裝在<span >...</span>標簽中。對于后者,我可以使用findAndReplaceDOMText庫,我認為前者也應該很容易。但我只能找到閱讀上傳檔案的答案。也就是說,使用
<input type="file" name="file" id="file">
上傳它。例如:如何使用Javascript讀取本地文本檔案并逐行讀取?,在客戶端用 JavaScript 逐行讀取檔案。谷歌搜索js read line by line只回傳 Node.js 的結果
uj5u.com熱心網友回復:
您可以使用Fetch API并將回應讀取為文本并逐行迭代
(async () => {
const response = await fetch("https://xn--qucu-hr5aza.cc/files/Một hệ thống niềm tin/Node list");
const data = await response.text();
const lines = data.split("\n");
console.log(lines)
})();
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/406961.html
標籤:
下一篇:如何在url中包含函式
