草庐IT

script-component

全部标签

javascript - react + 终极版 : Component does not update

尝试使用React+Redux,并且可能正在做一些明显愚蠢的事情,因为触发操作以通过网络获取数据的组件在获取数据时不会得到更新(重新呈现)。这是我的代码的相关部分:作为应用程序入口点的顶级index.js:importReactfrom'react';importReactDOMfrom'react-dom';import{Provider}from'react-redux';import{createStore,applyMiddleware}from'redux';import{Router,browserHistory}from'react-router';importredux

javascript - 与使用 eval 相比,包含 <script> 标签是否有性能提升?

我看到很多关于如何像这样动态添加代码的建议(source):varmyScript=document.createElement("script");myScript.setAttribute("type","text/javascript");myScript.innerHTML+='alert("Hello");';document.body.appendChild(myScript);相对于eval像这样eval('alert("Hello");');人们提示eval的性能下降和安全问题,但我无法想象如何添加标签会更快或更安全。编辑人们想知道为什么我要评估像alert("Hell

javascript - jQuery version 1.5 - ajax - <script> 标签时间戳问题

如果我使用其中包含脚本标记的ajax(jQuery)加载一些内容,jQuery1.5会将时间戳添加到脚本标记srcurl。请参见下面的示例。例子:满足我用ajax加载的内容:text1这是我将之前的内容插入页面后加载脚本代码的srcurl:.../js/abc-xyz.js?r=1.1&_=1297892228466有人知道为什么会这样吗?它只发生在jQuery1.5中。jQuery1.4.4不会发生这种情况。代码示例:$.ajax({url:content.html,type:'GET',data:someDataObject,success:function(data){//som

javascript - Protractor -ScriptTimeoutError : asynchronous script timeout: result was not received in 20 seconds

我是Protractor的新手,我正在尝试运行我的脚本。describe('Navigatorhomepage',function(){it('shouldproceedtologin',function(){browser.get('url');});it('Clickstheproceedbutton',function(){constproceedButton=element(by.id('auth-login-page-button'));proceedButton.click();});});但每当我运行它时,浏览器都会打开并继续访问该网站,然后等待20秒,然后我收到错误:S

javascript - @types/styled-components 重复标识符 FormData

如果我在我的项目中添加@types/styled-components,我将在构建输出中出现一堆错误:ERRORin/Users/me/projects/react/node_modules/@types/react-native/globals.d.ts(36,15):TS2300:Duplicateidentifier'FormData'.ERRORin/Users/me/projects/react/node_modules/@types/react-native/globals.d.ts(81,5):TS2717:Subsequentpropertydeclarationsmu

javascript - 通过 onclick 事件移除 <head> 标签中的特定 &lt;script&gt; 标签

functioninclude(filename,status){if(status=='on'){varhead=document.getElementsByTagName('head')[0];script=document.createElement('script');script.src=filename;script.type="text/javascript";head.appendChild(script);}else{//Thecodethatwipesthescripttagabove}}我想通过onclick事件删除标签中的特定标签。当我点击“CLOSE”按钮时,

javascript - Google Apps Script formatDate 使用用户时区而不是 GMT

在我使用的GoogleApps脚本中的函数中Utilities.formatDate()letformattedTimestamp=Utilities.formatDate(newDate(),"GMT","hh:mma");结果字符串是GMT时区的时间戳,但我需要它处于当前用户的时区,并考虑夏令时。文档链接到JavaSimpleDateFormatclassdocumentation但我找不到可用于替换GMT的有效时区列表。 最佳答案 您可以像这样直接获取电子表格时区:varaddedDate=sheet.getRange(1,1

javascript - Firefox 异常 'JavaScript component does not have a method named: "可用"'

我正在使用Django构建网络应用程序。我通过Ajax(jQueryv1.8.3)在Javascript中调用了一堆API。它们中的大多数都有效,但有一个特定的结果会返回一个状态为0的对象,并将此消息作为状态文本:[异常...“'JavaScript组件没有名为:'available''调用方法时:[nsIInputStream::available]”nsresult:“0x80570030(NS_ERROR_XPC_JSOBJECT_HAS_NO_FUNCTION_NAMED)”location:“JSframe::http://127.0.0.1:8000/media/js/jq

javascript - 在 Angular.js 中使用 &lt;script async> 标签

IlyaGrigorik建议使用尽可能标记。是否有一种干净、首选的方式来使用标签加载Angular.js应用程序,而不使用像require.js或angular-seed推荐的$script.js工具这样的工具?明显的问题是执行顺序。例如预防:UncaughtReferenceError:angularisnotdefinedhttps://www.igvita.com/2014/05/20/script-injected-async-scripts-considered-harmful/ 最佳答案 如果有一些有用的东西可以在没An

javascript - 错误 : attempted to update component that has already been unmounted (or failed to mount)

我是React的新手,由于这个错误,我无法呈现我的应用程序。由于尝试在卸载时设置状态,我试图呈现为元素的数据似乎不会呈现?我不确定我是怎么得到这个错误的,因为我正在componentDidMount中设置Data的状态。我该如何解决这个问题?error:attemptedtoupdatecomponentthathasalreadybeenunmounted(orfailedtomount)classProfileextendsReact.PureComponent{staticpropTypes={navigation:PropTypes.object,handleLogout:Pr