当使用--open标志启动时,如何激励webpack-dev-server打开我的publicPath?
目前它打开了一个浏览器选项卡到http:// localhost:3000,但我希望它直接打开http:// localhost:3000/app,这是我定义的公共路径.
当我在启动webpack-dev-server后手动键入http:// localhost:3000/app时,它按预期工作.
这是我的webpack.config.js到目前为止工作得很好:
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const webpack = require('webpack');
module.exports = {
entry: {
vendor: [
'jquery',
'angular'
],
app: './src/app/index.module.js',
libs: [
'./src/libs/pagination/dirPagination.js',
'./src/libs/sc-date-time/sc-date-time.js',
'./src/libs/msd-elastic.js',
'./src/libs/ng-textcomplete.js',
'./src/libs/highcharts/highslide-full.js',
'./src/libs/highcharts/Sankey.js'
]
},
output: {
filename: '[name].bundle.js',
chunkFilename: '[id].bundle.js',
path: path.resolve(__dirname, 'dist'),
publicPath: '/app/'
},
devtool: …
Run Code Online (Sandbox Code Playgroud) TD;DR
我花了一些时间跟踪我们的应用程序的性能,它实现了 highcharts。我发现,像 getBBox() 这样的函数确实经常触发“强制回流”。
如果你看看这个列表What force layout/reflow,触发回流的东西很长。
我的问题:
是否有至少一些列出的属性(特别是 offsetWidth/offsetHeight)的替代方案,不会触发回流?
<li *ngFor="let year of paper?.years" class="list-group-item">
<div>
<a routerLink="/viewpdf/{{year.questionPaper.fileId}}">Question Paper - {{year.formattedYear }}</a>
<a href="{{ downloadUrl }}/{{year.questionPaper.fileId}}" class="fa fa-download" aria-hidden="true"></a>
</div>
<div>
<a routerLink="/viewpdf/{{year.markScheme.fileId}}"> || Mark Scheme - {{year.formattedYear }}</a>
<a href="{{ downloadUrl }}/{{year.markScheme.fileId}}" class="fa fa-download" aria-hidden="true"></a>
</div>
</li>
Run Code Online (Sandbox Code Playgroud)
上面的代码工作正常。但我想检查每个 fileId 是否为空。如果为 null,则不会生成链接,反之亦然。
我已经设置了 *ngIf,下面是代码示例。但它不起作用。
<li *ngFor="let year1 of paper?.years" class="list-group-item">
<div *ngif="year.questionPaper.fileId != ''">
<a routerLink="/viewpdf/{{year.questionPaper.fileId}}">Question Paper - {{year.formattedYear }}</a>
<a href="{{ downloadUrl }}/{{year.questionPaper.fileId}}" class="fa fa-download" aria-hidden="true"></a>
</div>
<div *ngif="year.markScheme.fileId != ''">
<a routerLink="/viewpdf/{{year.markScheme.fileId}}"> || Mark Scheme - {{year.formattedYear …
Run Code Online (Sandbox Code Playgroud) 如果我创建timer()
一个执行如下:
timer(1000).subscribe(() => console.log("some logging"));
Run Code Online (Sandbox Code Playgroud)
我需要退订吗?
文档说:
如果未指定period,则输出Observable仅发出一个值
因此,据我所知RxJS
,这timer()
可能是在执行后完成的。但是我不太确定。没有大理石图,显示完成了timer()
。
注意
我不是在问如何退订。我需要知道timer()
没有给定时间的,是否需要完成,并且不需要取消订阅。
我基本上了解TS2322,但是在这种情况下,我听不懂。
我有一个给定的类定义,如下所示:
export class MyFaultyClass {
functionOrNull: () => void | null;
constructor() {
this.functionOrNull = null; // <- here comes the error TS2322
}
}
Run Code Online (Sandbox Code Playgroud)
我的问题
为什么不能将null分配给已定义的属性?
我的期望
constructor() {
this.functionOrNull = null; // OR
this.functionOrNull = () => {};
}
Run Code Online (Sandbox Code Playgroud)
编辑
这里是一个“工作”的例子:typescriptlang.org/playground 需要启用strictNullChecks。
标题说明了一切:如何将Enum分配给局部变量,例如:
export enum MyEnum {
TOP = "top",
RIGHT = "right",
BOTTOM = "bottom",
LEFT = "left"
};
const myEnum: MyEnum = MyEnum; // <-Error: Type 'typeof MyEnum' is not assignable to type 'MyEnum'.
Run Code Online (Sandbox Code Playgroud)
连结这里。
为了使有人想知道为什么要这样做:我想遍历AngularJs模板中的Enum值:
// component controller
export class MyClass {
public myEnum: MyEnum;
constructor() {
this.myEnum = MyEnum;
}
}
// component template
<ul>
<li ng-repeat="enum in $ctrl.myEnum">{{ enum }}</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
编辑
我知道我可以分配每个单独的值,例如:
constructor() {
this.myEnum = {};
this.myEnum.TOP = MyEnum.TOP;
this.myEnum.RIGHT= MyEnum.RIGHT;
this.myEnum.BOTTOM= MyEnum.BOTTOM; …
Run Code Online (Sandbox Code Playgroud)