Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/68.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 从数据库检索图像时,Jquery效果不起作用,但仅适用于静态图像_Javascript_Jquery_Angular7 - Fatal编程技术网

Javascript 从数据库检索图像时,Jquery效果不起作用,但仅适用于静态图像

Javascript 从数据库检索图像时,Jquery效果不起作用,但仅适用于静态图像,javascript,jquery,angular7,Javascript,Jquery,Angular7,我搜索了很多,但我没有找到解决这个问题的方法,我也是一个初学者 使用视觉代码2017 并使用visual studio 2017 api.netcore 2.2 我试图将函数添加到事件中 ngAfterViewInit 但它也不起作用 1. ngAfterViewInit(){ 这个.getAllPhoto(); }要处理动态创建的元素,需要使用on()函数,在本例中,请尝试以下操作: jQuery('body').on('load', function() { #your code her

我搜索了很多,但我没有找到解决这个问题的方法,我也是一个初学者 使用视觉代码2017 并使用visual studio 2017 api.netcore 2.2

我试图将函数添加到事件中 ngAfterViewInit

但它也不起作用 1.
ngAfterViewInit(){
这个.getAllPhoto();

}
要处理动态创建的元素,需要使用on()函数,在本例中,请尝试以下操作:

jQuery('body').on('load', function() {
  #your code here
}

这不是委派的事件处理程序。仅仅在()上使用
on
是不够的;您需要将它与正确的方法调用一起使用,例如:
$(父)。在(事件,子选择器,fn)
上,您是否在控制器类上实现了“AfterViewInit”?具体是:
$(.scroll”)。单击
更改为
$(文档)。在(“单击”、“.scroll”上,在组件名称索引index.ts getAllPhoto中的函数(){
AfterViewInit'(){返回这个。_httpClient.get(this.pathPhotos.toPromise()。然后(res=>{this.PhotoList=res;});}index.component.html@s中的代码库-nadezhnyy@freedomn-m jQuery(document).ready(函数($){$(文档).on(“单击“,”.scroll”,函数(){(函数(事件){event.preventDefault();$”('html,body')).animate({scrollTop:$(this.hash).offset().top},1000);});});});但在更改$(“.scroll”)时显示错误“消息”:“}”应为“}”。单击,因为缺少最终的
})
。正确设置代码格式,并且易于查看:。尽管如此,中心匿名函数是多余的,需要删除。将
事件
参数传递给事件处理程序,而不是一些随机的匿名函数: