草庐IT

parent_type

全部标签

javascript - react : Nested onclick also triggers parent

我使用slickcarousel的react版本制作了一个类似Netflix的carousel。您可以单击一个图block,然后该图block会展开以显示该图block的详细信息。例子:这要归功于Slicks处理动态高度的能力。我想在扩展部分添加一个关闭按钮(如最右侧所示)。但这就是我遇到的问题。如果我添加一个带有onClick处理程序的关闭按钮,它将始终触发显示展开部分的父级Onclick。showExpandedonclick函数只是设置一个showDetails状态。所以我的问题是:如何通过单击关闭按钮来设置状态,而不同时触发包装父级。我尝试了event.preventDefau

javascript - 继承和 TypeScript 错误 : X is not a constructor function type

我有一个父类(superclass),我希望从中继承其他两个类。下面列出了这些类(class)。当我编译时,试图继承的两个类提示父类(superclass)(给出相同的错误):“[类文件路径(在本例中为A)]不是构造函数类型”A.tsexportclassA{//privatefields...constructor(username:string,password:string,firstName:string,lastName:string,accountType:string){//initialisation}}B.tsimportA=require('./A);exportc

c# - "The Type or namespace ' AjaxControlToolkit' 无法找到...”的解决方案是什么?

Error3Thetypeornamespacename'AjaxControlToolkit'couldnotbefoundintheglobalnamespace(areyoumissinganassemblyreference?)D:\MyApp\table\PopUpdata.aspx.designer.cs5827table.我已经声明了这个javascript但问题是什么。 最佳答案 引用dll的方法是:在解决方案资源管理器中,选择项目。在“项目”菜单上,单击“添加引用”。“添加引用”对话框打开。选择指示您要引用的组件类

javascript - 错误 TS2314 : Generic type 'Promise<T>' requires 1 type argument(s)

我使用Promise和observables逻辑通过“get”从服务器获取数据。它一直工作到昨天。突然它开始抛出上述错误。请帮我找出错误。我收到“通用类型‘Promise’需要1个类型参数”错误。@Injectable()exportclassmyBlogService{//PropertytoholdrootserverURLi.ehostprivateserverUrl:string="app/data.json"constructor(privatehttp:Http){}//checkfunctioninservicetocheckcontroliscomingtoservic

javascript - typescript + 终极版 : exclude redux props in parent component

我正在为我当前的网络应用程序使用redux和typescript。定义通过@connect接收redux-actions的组件的props以及来自父级的props的最佳实践是什么?示例://mychild.tsxexportnamespaceMyChildComponent{exportinterfaceIProps{propertyFromParent:string;propertyFromRedux:string;//!!!!->ThisistheproblemactionsPropertyFromRedux:typeofMyReduxActions;//!!!!->Andthis

javascript - jQuery/JS : Get current URL parent directory

来自:http://www.site.com/example/index.html我怎样才能得到:http://www.site.com/example/并使用Javascript以及如何使用jQuery将其存储到变量中。提前致谢。 最佳答案 varmyURL="http://www.site.com/example/index.html";varmyDir=myURL.substring(0,myURL.lastIndexOf("/")+1); 关于javascript-jQuery/

javascript - 如何使用 type=module 脚本中的代码

这个问题在这里已经有了答案:ES6Modules:Undefinedonclickfunctionafterimport(4个答案)关闭4年前。我不明白为什么这个微不足道的代码不起作用:index.html:ShowMessageshowImport.js:importshowMessagefrom'/show.js';functionshowImportedMessage(){showMessage();}show.js:exportdefault"WhydoIneedthis?";exportfunctionshowMessage(){alert("Hello!");}它由NPMh

javascript - window.parent.location.href 或 window.top.location 哪个更好

我在一个项目中工作,在特定情况下我必须在错误页面上重定向。为此,我创建了Error.aspx页面。现在我正在使用window.top.location.href="../Error.aspx"并生成http://localhost/app_web/Error.aspx并且它的工作正常,除了一次(显示消息http://xyz/ErrorPage.aspx'不存在。)。那么任何人都可以建议哪个是更好的选择。谢谢 最佳答案 top“优于”parent如果您的目的是将您的页面framebust到顶层,因为您的页面可能位于一个框架内,而该框架

javascript - 传单绘制插件 : How to hide/show drawing tools by Layer Type dynamically

我在项目中使用绘图插件,我想知道如何按图层类型隐藏/显示绘图工具?例如,假设我有2个图层,其中一个类型是多边形,另一个是线。如果用户选择多边形层,我想隐藏画线工具。之后,如果用户选择线层,我想隐藏多边形绘图工具。我看过here但是这个例子使工具成为静态的,我想动态地改变。我该怎么做?我们将不胜感激。 最佳答案 我自己解决了。我在map初始化时添加了这个绘制控件。drawControl=newL.Control.Draw({draw:{position:'topleft',polygon:false,polyline:false,re

javascript - 错误 :Property 'select' does not exist on type HTMLElement

functioncopy(){varUrl=document.getElementById("Id");Url.select();//errordocument.execCommand("Copy");//browsercopy}如上。我正在尝试制作一个在浏览器中复制文本的功能。但是出现了标题错误在typescript中。我认为select()是有效的(link),因为我在演示中使用它时可以正确复制。我的ts版本是2.8.1 最佳答案 您需要添加一个typeassertion:varUrl=document.getElementBy