草庐IT

styled-component

全部标签

javascript - JQuery - 获取宽度 : auto from inline style

我正在尝试使用jquery获取元素的内联属性:width:auto。一旦我获得宽度,.width()就会返回一个px值,而不是auto。这是我需要的示例:我有一个img设置了这个内联样式:我需要将该图像包装在a中,以使图像可点击。我还需要获取图像样式并将其移动到anchor标记://---getheight,widthandentirestylevarimgHeight=$("#image").height();varimgWidth=$("#image").width();varimgStyle=$("#image").attr("style");//---removeinlines

javascript - style.left 和 element.offsetLeft 有什么区别

谁能告诉我style.left和element.offsetLeft有什么区别,是一样的吗? 最佳答案 element.offsetLeft返回当前元素的左上角在offsetParent节点内向左偏移的像素数。elem.style.left获取样式属性的左侧属性 关于javascript-style.left和element.offsetLeft有什么区别,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.co

javascript - Angular 2/4 : How to POST HTML form (Not ajax) thru component on callback of 1st ajax submit?

我想通过以老式方式(非Ajax)发布输入字段来将表单提交到外部站点,它也提交了但是Angular在跳转到外部页面之前在控制台中给我错误。我在HTML(模板)中使用了以下代码在组件中onSubmit(obj:any){if(!this.form.valid){this.helper.makeFieldsDirtyAndTouched(this.form);}else{this.loader=true;//savedatainonline_payment_ipnthis.paymentService.saveOnlinePaymentIpn({},'paypal').subscribe(r

javascript - 无法读取 null 的属性 'style'

由于一些奇怪的原因,我得到了一个奇怪的错误。我有一个元素(我用PHP定义的)最终看起来像这样:...somehtmlinputsandstuff....我通过Chrome的InspectElement确定。现在,当我尝试用这个编程方式解决它时:document.getElementById("1_area_1_5").style.display='none';我收到Cannotreadproperty'style'ofnull错误。我不知道这到底是什么意思,有什么帮助吗? 最佳答案 错误意味着该元素不存在。那是因为你打错了你写了1而

javascript style.width 在具有过渡文档类型的 firefox 中不起作用

我有一个脚本可以让一个小的DIV在页面上弹出。在IE中一切正常,如果我删除DOCTYPE,在FF中一切正常,但是当DOCTYPE为XHTML/Transitional时,在Firefox中,宽度不会改变。this.container.style.visibility="visible";alert("this.container.style.widthbefore="+this.container.style.width)this.container.style.width=this.width;alert("this.container.style.widthafter="+this

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 - Angular 2 : passing ALL the attributes to the child component

甚至不知道解释这个问题的正确术语所以,想象一下这个场景......有一个form-input-component并捕获一些属性并将其传递给内部的标记所以,这就是标记,希望它是不言自明的......显然在我的ts中@Input()label:string='';@Input()placeholder:string='';然后在View中我有一些东西{{label}}现在,到目前为止一切正常......但是假设我想在它周围添加验证规则......或者添加我没有通过@Input()捕获的其他属性我如何传递来自的任何其他内容?到我的在View中? 最佳答案

javascript - react : 'this.state' is undefined inside a component function

我在组件内的函数中访问this.state时遇到问题。我已经找到了this关于SO的问题并将建议的代码添加到我的构造函数中:classGameextendsReact.Component{constructor(props){super(props);...this.state={uid:'',currentTable:'',currentRound:10,deck:sortedDeck};this.dealNewHand=this.dealNewHand.bind(this);this.getCardsForRound=this.getCardsForRound.bind(this)

javascript - d3 : what is the self as in d3. select(self.frameElement).style ("height", height + "px");

我在许多D3示例中看到过如下语句。但是,我无法找出它的含义。特别是,我不知道这个self变量指的是什么。此外,这是否体现了某种D3魔术/惯例,或者它只是一个临时的东西?非常感谢。d3.select(self.frameElement).style("height",height+"px");顺便说一句,here是我复制上面语句的例子。 最佳答案 self:如果没有重新定义(通常作为this的副本),那么它就是始终指向windowwindow对象。因此它们可以互换使用。window.frameElement:返回嵌入窗口的元素(例如或

javascript - react .js : Is it possible to namespace child components while still using JSX to refer to them?

假设我有一个名为ImageGrid的组件定义如下:window.ImageGrid=React.createClass({render:function(){return();}});如您所见,它包含一个名为ImageGridItem的子React组件。.其定义如下。window.ImageGridItem=React.createClass({render:function(){return(something);}});只要两者都是window的直接属性,这就可以正常工作.但这有点可怕,所以我想将我所有的react组件分组到window.myComponents的命名空间下。例如。