在angular2+中使用外部库;网页包应用程序
我是angular2的新手,正在编写一个新的客户端angular2 cli生成的应用程序(带有webpack2)。我的组件需要使用这个外部库中的splunkjs对象。 我希望能够访问此splunkjs对象,但在angular2应用程序的组件中无法访问:在angular2+中使用外部库;网页包应用程序,angular,webpack-2,Angular,Webpack 2,我是angular2的新手,正在编写一个新的客户端angular2 cli生成的应用程序(带有webpack2)。我的组件需要使用这个外部库中的splunkjs对象。 我希望能够访问此splunkjs对象,但在angular2应用程序的组件中无法访问: var http = new splunkjs.JQueryHttp(); 在一个独立的javascript中,我可以使用: <html> <head> <title>Test</title
var http = new splunkjs.JQueryHttp();
在一个独立的javascript中,我可以使用:
<html>
<head>
<title>Test</title>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="splunk.js"></script>
<script type="text/javascript" charset="utf-8">
function test() {
var http = new splunkjs.JQueryHttp();
console.log(' http is ' + JSON.stringify(http));
}
</script>
</head>
<body>
<button type="button" onclick="test()">Test</button>
</body>
试验
功能测试(){
var http=new splunkjs.jqueryhtp();
log('http是'+JSON.stringify(http));
}
试验
在我的angular组件中,上面要做什么?通过在package.json中添加jquery和splunk sdk作为依赖项,然后在“脚本”部分的.angular-cli.json中添加其dist脚本的路径来解决。这是一个很好的参考