Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/394.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 标签中的代码<;脚本>;在VScode的component.html文件中不工作,请参阅_Javascript_Html_Angular_Visual Studio Code - Fatal编程技术网

Javascript 标签中的代码<;脚本>;在VScode的component.html文件中不工作,请参阅

Javascript 标签中的代码<;脚本>;在VScode的component.html文件中不工作,请参阅,javascript,html,angular,visual-studio-code,Javascript,Html,Angular,Visual Studio Code,我的问题是,即使我已经包括了标签 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> 在index.html中 在component.html中,标记中的代码没有被执行 检查时无错误 附言:我用了下面的祝酒词 <script src="https://code.jquery.com/jquery-2.2.4.min.js" i

我的问题是,即使我已经包括了标签

 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

在index.html中

在component.html中,标记中的代码没有被执行

检查时无错误

附言:我用了下面的祝酒词

<script
  src="https://code.jquery.com/jquery-2.2.4.min.js"
  integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="
  crossorigin="anonymous"></script>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js"></script>

编辑:

代码:


折叠/扩展
#容器{
保证金:0自动;
宽度:80%;
溢出:自动;
}
表格{
保证金:0自动;
宽度:95%;
溢出:自动;
字体系列:helvetica、arial、无衬线字体;
字体大小:14px;
颜色:#333333;
边框宽度:1px;
边框颜色:#666666;
边界塌陷:塌陷;
文本对齐:居中;
}
table.gridtable th{
边框宽度:1px;
填充:8px;
边框样式:实心;
边框颜色:#666666;
背景色:#F6B4A5;
}
table.gridtable td{
边框宽度:1px;
填充:8px;
边框样式:实心;
边框颜色:#666666;
}
顾客
产品
日期
价值
顾客01
客户01产品0130 10 2017974.57
客户01产品020412017634.50
客户01产品0330 10 2017974.57
客户01产品0404 12 2017634.50
客户01产品0530 10 2017974.57
客户01产品0604 12 2017634.50
客户01产品0730 10 2017974.57
客户01产品0804 12 2017634.50
客户01产品0930 10 2017974.57
客户01产品1004 12 2017634.50
客户02
客户02产品0104 12 2017634.50
客户0230产品0230 10 2017974.57
客户02产品0304 12 2017634.50
客户02产品0430 10 2017974.57
客户02产品0504 12 2017634.50
顾客03
客户03产品0130 10 2017974.57
客户03产品020412017634.50
客户0330产品0330 10 2017974.57
客户03产品0404 12 2017634.50
客户03产品0530 10 2017974.57
客户03产品0604 12 2017634.50
客户03产品0730 10 2017974.57
客户03产品0804 12 2017634.50
负载
$(文档).ready(函数(){
$('#按钮1')。单击(函数(){
$(“#tableMain”).append('customer 04');
$(“#tableMain”).append('customer 04product 0130 10 2017974.57');
$(“#tableMain”).append('customer 04product 020412 2017634.50');
$(“#tableMain”).append('customer 04product 0330 10 2017974.57');
$(“#tableMain”).append('customer 044 product 0404 12 2017634.50');
$(“#tableMain”).append('customer 04product 0530 10 2017974.57');
});
//折叠和扩展节
//$('.breakrow')。单击(函数(){
$('tableMain')。在('click','tr.breakrow',function()上{
$(this).nextUntil('tr.breakrow').slideToggle(200);
});
});
当此html文件作为'file:///D:/Angular/node-v8.11.4-win-x64/node-v8.11.4-win-x64/foldername%20(1)/folder1/projectname/src/app/collapse test/collapse test.component.html',它可以按预期工作


但是,当通过项目流执行时,它无法按预期工作。

组件.html中访问脚本不是一种正确的方法。您可以在
index.html中添加所有外部脚本引用

如果您想在内部访问cdn以外的内容,请安装特定的库
npm install[packageName]@latest
此注释行将添加该包,您可以在
scripts
array或
styles
array上的
angular.json
文件中引用它


希望这对您有所帮助-感谢快乐编码!!

您不能像在角度组件中那样添加脚本标记。 如果要安装jQuery,请按以下方式操作:

首先使用npm安装jQuery,如下所示

npm install jquery — save
"scripts": [ "../node_modules/jquery/dist/jquery.min.js" ]
然后转到angular cli项目文件夹根目录下的./angular-cli.json文件,找到scripts:[]属性,并包括jQuery的路径,如下所示

npm install jquery — save
"scripts": [ "../node_modules/jquery/dist/jquery.min.js" ]
包含jQuery后,请停止运行Angular CLI应用程序,然后使用ng serve重新运行它

现在要使用jQuery,您所要做的就是将它导入到您想要使用jQuery的任何组件中,如下所示

import * from 'jquery';
如果您确实想插入内联脚本标记,请参阅此处的asnwer:

的可能重复,但它是另一个查询。已安装软件包;但其中的代码不起作用。