我不明白出了什么问题.我检查了其他论坛谈论翻译和巴贝尔.我需要做什么?
node -v
v5.5.0
Run Code Online (Sandbox Code Playgroud)
我的代码:
import recast from 'recastai'
Run Code Online (Sandbox Code Playgroud)
和错误
(function (exports, require, module, __filename, __dirname) { import recast from 'module1'
^^^^^^
SyntaxError: Unexpected token import
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:387:25)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Function.Module.runMain (module.js:447:10)
at startup (node.js:139:18)
at node.js:999:3
Run Code Online (Sandbox Code Playgroud) 我有一个组件A,它在模板中使用组件B,c,D:
###template-compA.html
<comp-b></comp-b>
<comp-c [myinput]="obj.myinput"></comp-c>
<comp-d ></comp-d>
Run Code Online (Sandbox Code Playgroud)
...等等
为简化起见,假设它们只是组件A中的一个指令:
###template-compA.html
<comp-b></comp-b>
Run Code Online (Sandbox Code Playgroud)
我的comp-b有自己的依赖项(服务或其他comp).
如果我想以这种方式测试comp-a:
TestBed.configureTestingModule({
declarations: [comp-A],
imports: [ReactiveFormsModule],
}).overrideComponent(FAQListComponent, {
set: {
providers: [
{ provide: comp-AService, useValue: comp-AListSVC }
]
}
})
.compileComponents();
Run Code Online (Sandbox Code Playgroud)
它不会正常工作.所以我这样做:
TestBed.configureTestingModule({
declarations: [comp-A, comp-B],
imports: [ReactiveFormsModule],
}).overrideComponent(FAQListComponent, {
set: {
providers: [
{ provide: comp-AService, useValue: comp-AListSVC }
]
}
})
.compileComponents();
Run Code Online (Sandbox Code Playgroud)
它也不起作用,因为comp-b没有自己的依赖项.在这里我很困惑,如果我必须每次导入和重新安装所有其他组件,我怎么能进行单元测试?它看起来像是一项非常大的工作.还有另外一种方法吗?使用具有自己的依赖关系的嵌套组件测试组件的最佳实践是什么?
非常感谢,
斯特凡.
我们构建了一个由Apache服务器提供服务的Angular v> 4应用程序.我知道它存在Angular Universal for Node服务器以允许服务器端呈现.是否存在Apache Server的任何等效项?
谢谢.
我是一名 JS 开发者。使用 NPM,您可以使用通配符或关键字告诉 npm 获取最新的次要、主要...等 1.2.x 。\n 有没有办法使用maven 3执行此操作?
\n\n <properties>\n <artifact.version>1.2.0-RC1</artifact.version>\n <my-dep.version>1.5.0-RC*</my-dep.version>\n </properties>\nRun Code Online (Sandbox Code Playgroud)\n\n在构建时,每次构建时我都会获得最新的 RC(RC1、RC2...等)。
\n\n我找到了这个答案,但对于 Maven 2 :\n如何告诉 Maven 使用最新版本的依赖项?
\n\n谢谢
\n\nSt\xc3\xa9phane。
\n我正在使用 WebStorm。在Ctrl + Click我能够跳转到定义文件:
import myClass from '../../../../core/myClass';
Run Code Online (Sandbox Code Playgroud)
但是如果我使用的是jsconfig.json文件,它就不起作用。
/// jsonfig.json
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"Core/*": ["./app/bundles/core/*"],
}
},
"exclude": [
"node_modules"
]
}
Run Code Online (Sandbox Code Playgroud)
在我的文件中,我替换为:
import myClass from 'Core/myClass';
Run Code Online (Sandbox Code Playgroud)
捆绑工作完美,但不能使用 WebStorm 跳转到文件。
知道什么设置吗?
我正在制作一个Angular 4应用程序.组件订阅Observable.有时Observable调用相同的url.例如,在任何http请求之前,如果需要,请"刷新访问令牌".但是,如果我发出不同的3个http请求,它将"刷新(如果需要)"刷新令牌的3倍.
那么如何只让一个http获取一个刷新的访问令牌,并使其他可观察者'等待'第一个?(我知道'等'不是Observables的好词).
public get(url: string, options?: RequestOptionsArgs): Observable<Response> {
return this.getAccessToken().mergeMap(accessToken => {
return this.http.get(url, options);
});
}
Run Code Online (Sandbox Code Playgroud)
//而且
this.get('www.myapi.com/one').subscribe(data=>console.log('one',data))
this.get('www.myapi.com/two').subscribe(data=>console.log('two',data))
this.get('www.myapi.com/three').subscribe(data=>console.log('three,data))
Run Code Online (Sandbox Code Playgroud) 我们正在实施谷歌分析。我们想检索 url、params 和组件以在 GA 中标记它们。
this.router.events
.pipe(
filter(event => event instanceof NavigationEnd)
)
.subscribe((event: NavigationEnd) => {
event.urlAfterRedirects;
});
Run Code Online (Sandbox Code Playgroud)
例如导航到 /tab/brands/12/details/55
/tab/brands/:BrandId/details/:productId
Run Code Online (Sandbox Code Playgroud)
我们可以找到 url,但找不到组件名称和参数。任何的想法?
错误:@import“ ./styles/mixins”; ^仅在规则,指令,mixin包含项或其他属性内允许使用属性。
我的scss文件就是这样简单:
@import "./styles/mixins";
// There shouldn't be anything else
// Set my variables
@import "styles/variables";
@import "styles/core-style";
@include font-importer("Raleway Regular",'normal',400,"./assets/fonts/Raleway/Raleway-Regular.ttf");
@include font-importer("Raleway Bold",'normal',700,"./assets/fonts/Raleway/Raleway-Bold.ttf");
@include font-importer("Raleway Light",'normal',300,"./assets/fonts/Raleway/Raleway-Light.ttf");
@include font-importer("Raleway Medium",'normal',500,"./assets/fonts/Raleway/Raleway-Medium.ttf");
Run Code Online (Sandbox Code Playgroud)
这是什么意思 ?我不理解Sass错误。我不知道在哪里看。我需要做什么 ?
谢谢,
斯特凡。
我正在使用BigNumberetherjs,并且正在执行这个非常简单的操作:
const cost = BigNumber.from(3)
.div(BigNumber.from(1000))
.mul(BigNumber.from(3));
console.log(cost.toString());
Run Code Online (Sandbox Code Playgroud)
它输出“0”,但应该是 0.09。
为什么?我究竟做错了什么?
angular ×4
javascript ×2
apache ×1
babel ×1
css ×1
dependencies ×1
ether ×1
http ×1
jasmine ×1
java ×1
maven ×1
node.js ×1
observable ×1
routing ×1
rxjs ×1
sass ×1
server-side ×1
shortcut ×1
unit-testing ×1
webstorm ×1