小编Ben*_*inK的帖子

如何删除 div 右侧由于自动换行而出现的空白?

将浏览器窗口重新缩放到非常小的尺寸时,总会有一些尺寸会导致右侧的文本由于自动换行而产生一些空间。如何将其与自动换行右对齐?

我尝试过的:

display: inline;
display: inline-block;
float: left;
white-space: nowrap; // not giving me the expected results as I want to keep the padding and the breaks
Run Code Online (Sandbox Code Playgroud)

.page-container {
  padding: 160px 48px 48px 48px;
  margin: 0 auto;
  max-width: calc(1080px + 96px);
  height: 90%;
  width: 100%;
  display: flex;
  justify-content: end;
  align-items: flex-end;
}

.title-container {
  background-color: red;
  max-width: 60vw;
  text-align: left;
}
Run Code Online (Sandbox Code Playgroud)
<div className="page-container">
  <div className="title-container">
    <h1>
      Text <br /> More Text
    </h1>
    <br />
    <h3>Item1 / Item2 / Item3 / …
Run Code Online (Sandbox Code Playgroud)

html css

5
推荐指数
0
解决办法
1143
查看次数

Typescript 中的 reduce() 函数实例化空对象

我正在尝试将我的 Javascript 函数转换为它的 Typescript 版本,但我无法摆脱读取的带下划线的代码acc[curr.name](在 VSCode 中)。将鼠标悬停在其上时会显示:

元素隐式具有“any”类型,因为“string”类型的表达式不能用于索引类型“{}”。在类型“{}”上找不到带有“string”类型参数的索引签名。

我正在按键名称计算出现次数。

我应该在哪里定义类型以及为什么空对象或带有数字的对象不起作用。我不确定如何解决它,因为我尝试了多种方法,例如:

data.reduce<{}>()data.reduce<{property: number}>()

代码:

const data = [
  { name: "name1", },
  { name: "name1", },
  { name: "name1", },
  { name: "name1", },
  { name: "name2", },
  { name: "name2", },
  { name: "name2", },
  { name: "name1", },
];

// count data by key name
const resultData = data.reduce((acc, curr) => {
  return acc[curr.name] ? ++acc[curr.name] : (acc[curr.name] = 1), acc;
}, {});
Run Code Online (Sandbox Code Playgroud)

运行时结果:

const …
Run Code Online (Sandbox Code Playgroud)

javascript typescript

4
推荐指数
1
解决办法
6310
查看次数

使用递归文件搜索并排除带有pathlib的startswith()

我想用 pathlib 递归搜索所有文件夹中的所有文件,但我想排除以“.”开头的隐藏系统文件 (如'.DS_Store')但我在pathlib中找不到像startswith这样的函数。如何在pathlib中实现startswith?我知道如何使用 os.

def recursive_file_count(scan_path):
    root_directory = Path(scan_path)
    fcount = len([f for f in root_directory.glob('**/*') if f.startswith(".")])
    print(fcount)
Run Code Online (Sandbox Code Playgroud)

python operating-system for-loop pathlib

1
推荐指数
1
解决办法
3595
查看次数

使用 Google Apps 脚本将图像从云端硬盘插入 Google Spresheet 单元格

我已经浏览了有关该主题的所有线程。从 blob 到 URL 等等,通过 apps-script 将图像插入单元格,但似乎没有任何效果。大多数帖子都没有给出足够好的解决方案来追溯错误。所以我想在这里找到我的问题的答案。下面是我的代码。我也很想讨论不同方法的优点。据我所知,在处理 G-Drive 中已有的图像时,Blob 似乎是最简单的之一。

function getGDriveFilesIntoCell() {

  var dApp = DriveApp;  // Store GDrive App in a function
  var folderIter = dApp.getFoldersByName("Training_folder");  // Get folder by name
  var foundfolder = folderIter.next();  // next allows to Iterate through the found folders
  Logger.log(foundfolder);  // Print into the logs the found folder of foundfolder

  var ss = SpreadsheetApp.getActiveSpreadsheet(); //.getActiveSheet();  // Calls the Spreadsheet App and the current active Spreadsheet
  var sheet = ss.getSheets()[0];  // Get first sheet …
Run Code Online (Sandbox Code Playgroud)

google-sheets google-apps-script

0
推荐指数
1
解决办法
2403
查看次数