google-chrome-extension - Chrome 扩展换行符 (\n) 在 popup.html 中不起作用
问题描述
我的 popup.js 接收一个数组,替换,
为\n
popup.html 页面并将元素打印到该页面。出于某种原因,没有形成换行符,相反,我看到的只是,
过去的小空间。
popup.html
<!DOCTYPE html>
<html>
<head>
<link href="popup.css" rel="stylesheet" type="text/css">
</head>
<body>
<h3>Header issues</h3>
<p class="hdrs">Fetching headers..</p>
<script src="popup.js"></script>
</body>
</html>
popup.js:
function fixArrayLines(response) {
var sorted = response.toString().replace(/,/g,',\n');
return sorted;
}
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {type: "getHDR"}, function(response) {
var sortedRsp = fixArrayLines(response);
document.querySelector("p.hdrs").textContent = sortedRsp;//if response null, replaces with empty
});
收到的数组(名为“响应”):
var response =[aba,baba,gaga]
popup.html 页面中出现意外结果
aba baba gaga
我有一个关于最小弹出窗口大小的小 CSS 指令 - 仅此而已,并且清单设置正确。为什么会这样?如何逐行正确地对数组成员进行排序?(以这种方式或任何其他方式)?
解决方案
推荐阅读
- laravel - 无法将 vue 相关的 npm 包包含到我的 Laravel + Vue 项目中
- sql-server - 无法连接到 SQL Server 获取防火墙规则错误
- excel - ms excel中的多个连接饼图
- html - HTML 文件中两种颜色的边框设计
- laravel - 压缩时我的 app.js 文件中的 \u0 个字符
- swift - 使用 CollectionViewCell _Swift 将 Firebase 数据传递给 DetailView
- android - 反编译修改后的apk没有安装
- neo4j - 如何在反应式 Spring webflux 应用程序中使用 Neo4j 而不会导致任何阻塞?
- javascript - 如何在javascript中按多个模式拆分字符串?
- objective-c - 尝试将 NSDictionary 从 swift 类传递到目标 c 类时发送到实例的无法识别的选择器