我发现所有将 svg 添加到 AngularCli 组件的教程都建议将其插入到 html 模板中,如下所示:
<div>
<svg viewBox="0 0 250 250">
<svg:g class="group">
<svg:polygon class="shield" points="125,30 125,30 125,30 31.9,63.2 46.1,186.3 125,230 125,230 125,230 203.9,186.3 218.1,63.2" />
<svg:path class="a" d="M125,52.1L66.8,182.6h0h21.7h0l11.7-29.2h49.4l11.7,29.2h0h21.7h0L125,52.1L125,52.1L125,52.1L125,52.1
L125,52.1z M142,135.4H108l17-40.9L142,135.4z"/>
</svg:g>
</svg>
</div>
Run Code Online (Sandbox Code Playgroud)
但我希望保持模板清晰,并且只在其中插入几个带有 url 的标签到分隔的 svg 文件,就像这样:
<svg class="star">
<use xlink:href="../../../assets/images/svg/star.svg"
x="0"
y="0" />
</svg>
Run Code Online (Sandbox Code Playgroud)
如何在组件中使用分离的 svg 文件?
我需要在文件开头进行偏移(一些沉默),所以我尝试了:
./ffmpeg -itsoffset 100 -i 3.mp3 offset_test.mp3
Run Code Online (Sandbox Code Playgroud)
但这不起作用。
如何使用 ffmpeg 添加偏移量到音频文件?
有一个无限滚动到底部的示例。
var $ol = document.querySelector("ol");
function load_more() {
var html = "";
for (var i = 0; i < 5; i++) html += '<li></li>';
$ol.innerHTML += html;
}
$ol.addEventListener("scroll", function() {
if ($ol.scrollHeight - $ol.scrollTop === $ol.clientHeight)
load_more();
});Run Code Online (Sandbox Code Playgroud)
<ol>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ol>
Run Code Online (Sandbox Code Playgroud)
有一个jsfiddle 示例
我如何像这样无限滚动,但要使用js?
package.json中有脚本:
"scripts": {
"typedoc": "npx typedoc --out docs src/main.ts --exclude ./node_modules/**",
}
Run Code Online (Sandbox Code Playgroud)
我运行它
npm run typedoc
Run Code Online (Sandbox Code Playgroud)
并得到一个错误:
解析“...node_modules/**”附近时,JSON 中位置 920 处出现意外标记 }
我该如何解决?
这是一个例子
有一个包含项目列表的组件:
class HomeComponent {
text = 'foo';
testObject = {fieldFirst:'foo'};
itemList = [
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8 This one should be scrolled into viewport',
'9',
'10',
'11',
'12',
];
scrollToElement() {
// Do scroll there
}
}
Run Code Online (Sandbox Code Playgroud)
它的模板是:
<button (click)="scrollToElement()">Scroll To 8th Element</button>
<div class="wrapper">
<li *ngFor="let item of itemList">{{item}}</li>
</div>
Run Code Online (Sandbox Code Playgroud)
以及风格:
.wrapper {
max-height: 300px;
overflow-y: scroll;
}
Run Code Online (Sandbox Code Playgroud)
如何将第 8 个元素滚动到“wrapper”div 的视口中?
更新
这个答案并不能解决问题,因为问题不是如何使元素聚焦,问题是如何滚动到它。
如何通过 css 选择器在整个文档中找到元素,而不仅仅是在 Angular2 (ngx) 的子元素中?
有时我会在 Chrome 中进行一些 css 草图更新,看看这正是我需要的更新。然后我将它们添加到 css 文件中。在这一步,我必须保存 css 文件。但是保存后我在 Chrome 中丢失了我的草图更新。如果我正确地在 css 文件中进行所有更改就可以了。但如果我打印错误或忘记复制一些 css 样式,我必须检查我做错了什么,因为我无法在 Chrome 中检查草图更新。
ng服务一次时如何防止自动重新加载页面?
html google-chrome command-line-interface angular-cli angular
我安装了 typedoc:
npm install typedoc --save-dev
Run Code Online (Sandbox Code Playgroud)
然后将 typedocOptions 添加到 tsconfig.json 中:
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
// ...some lines there
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2018",
"dom"
],
"emitDecoratorMetadata": true
},
"angularCompilerOptions": {
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true
},
"typedocOptions": {
"mode": "modules",
"out": "docs"
}
}
Run Code Online (Sandbox Code Playgroud)
然后我这样做:
npx typedoc --out docs src/index.ts
Run Code Online (Sandbox Code Playgroud)
并得到错误:
Error: Tried to set an option (mode) that was not declared.
Run Code Online (Sandbox Code Playgroud)
我该如何解决?
我需要将 ffmpeg 输出读取为管道。有一个代码示例:
public static void PipeTest()
{
Process proc = new Process();
proc.StartInfo.FileName = Path.Combine(WorkingFolder, "ffmpeg");
proc.StartInfo.Arguments = String.Format("$ ffmpeg -i input.mp3 pipe:1");
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardInput = true;
proc.StartInfo.RedirectStandardOutput = true;
proc.Start();
FileStream baseStream = proc.StandardOutput.BaseStream as FileStream;
byte[] audioData;
int lastRead = 0;
using (MemoryStream ms = new MemoryStream())
{
byte[] buffer = new byte[5000];
do
{
lastRead = baseStream.Read(buffer, 0, buffer.Length);
ms.Write(buffer, 0, lastRead);
} while (lastRead > 0);
audioData = ms.ToArray();
}
using(FileStream s = …Run Code Online (Sandbox Code Playgroud) ListWithAllItems 包含两种类型的项目:我想要选择的项目和我不选择的项目.
listForExcluding 包含我应该排除的项目:
List<string> listForExcluding = ...;
Run Code Online (Sandbox Code Playgroud)
所以我用两个字符串来做:
List<string> x = ListWithAllItems.ToList();
x.RemoveAll(p => listForExcluding.Any(itemForExclude => itemForExclude == p));
Run Code Online (Sandbox Code Playgroud)
如何使用Any()而不是RemoveAll()用一行获取此查询?
代码是
time.ToString("yyyyMMddHmmsFFF"));
Run Code Online (Sandbox Code Playgroud)
并且在 2019 年之后返回“20190121153530”前导零。
如何格式化日期以获得没有前导零的“2019121153530”?
用户在 System.in 中键入
1 2 3 4 44 50 and so on
Run Code Online (Sandbox Code Playgroud)
我需要从中获取 int 数组,所以我的解决方案是:
import java.util.Scanner;
public class Program
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
String tempString = in.nextLine();
int tempArray[] = tempString.split(" ");
result[] = tempArray(tempArray.length);
for(int i=0; i<result.length; i++)
{
result[i] = Integer.parseInt(tempArray[i]);
}
}
}
Run Code Online (Sandbox Code Playgroud)
有没有办法简化代码?
html ×5
angular ×4
javascript ×4
c# ×3
audio ×2
css ×2
ffmpeg ×2
npm ×2
scroll ×2
typedoc ×2
typescript ×2
.net-core ×1
angular-cli ×1
angular5 ×1
any ×1
arrays ×1
converters ×1
date ×1
datetime ×1
formatting ×1
import ×1
input ×1
int ×1
java ×1
leading-zero ×1
linq ×1
list ×1
node.js ×1
offset ×1
pipe ×1
removeall ×1
svg ×1
system ×1
video ×1