草庐IT

parent-last

全部标签

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 - 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 和正则表达式 : remove space after the last word in a string

我有一个这样的字符串:varstr='aaaaaa,bbbbbb,ccccc,ddddddd,eeeeee';我的目标是删除字符串中的最后一个空格。我会用,str.split(0,1);但是如果字符串中最后一个字符后没有空格,这将删除字符串的最后一个字符。我想用str.replace("regex",'');我是RegEx的初学者,感谢任何帮助。非常感谢。 最佳答案 在谷歌上搜索“javascripttrim”,您会发现许多不同的解决方案。这是一个简单的例子:trimmedstr=str.replace(/\s+$/,'');

javascript - Vue.js: 从 "parent"Vue 获取数据

我有一个(不可更改的)DOM结构如下:.........还有两个js文件:index.js:varchild=require('childVue');module.exports=newVue({el:'#indexVue',...});childVue.js:module.exports=newVue({el:'#childVue',methods:{something:function(){//Parentdataneededhere...},...}});如图所示,我需要indexVue的数据在childVue.有什么办法可以传递给它吗?我试图将它传递给带有(v-on="clic

javascript - Angular 翻译 : Child Module translatePartialLoader urlTemplate overrides the Parent Module translatePartialLoader urlTemplate

我必须使用多个具有不同urlTemnplate的translatePartialLoader。我正在使用angular-translate-loader-pluggable。看起来子模块urltemplate覆盖了父模块urltemplate父模块配置$translateProvider.useLoader('$translatePartialLoader',{urlTemplate:__env.hostUrl+'/*****/****/localization/resource_bundle?bundle_name={part}&locale={lang}'});$translate

javascript - ES6 继承 : uses `super` to access the properties of the parent class

Javascript的super关键字,当我在Chrome、Babel、TypeScript上运行代码时,我得到了不同的结果。我的问题是哪个结果是正确的?规范的哪一部分定义了这种行为?以下代码:classPoint{getX(){console.log(this.x);//C}}classColorPointextendsPoint{constructor(){super();this.x=2;super.x=3;console.log(this.x)//Aconsole.log(super.x)//B}m(){this.getX()}}constcp=newColorPoint();

javascript - NodeJS - 如何让生成的 child 与 parent 沟通?

我正在尝试这个:varchild=spawn('node',args,{cwd:parentDir,stdio:'ipc'});(args是一个参数数组)但它给出了以下错误:TypeError:Incorrectvalueofstdiooption:ipc这确实有效,所以问题似乎确实出在stdioipc参数上:varchild=spawn('node',args,{cwd:parentDir});这也有效:varchild=spawn('node',args,{cwd:parentDir,stdio:'pipe'});我读到这个:http://nodejs.org/api/child_

javascript - Angular 2 : Validate child component form fields from the parent component

问题陈述:父组件有标签和一些里面的标签,子组件也有一些标签,父组件有一个我们正在验证提交表单时的表单字段。如何验证子组件来自父组件的字段submit表格?要求:如果父组件的表单包含带有input的子组件模板中的组件,然后是这些input如果从父组件提交,组件应该在点击时验证。调查结果:SO中有很多帖子有相同的问题陈述,但没有找到任何合适的解决方案。以下所有帖子都验证了整个表单,但我的要求是验证子组件中的每个字段。Angular2validationtogetherwiththechildcomponentAllowtemplate-drivenforminputsacrossacomp

javascript - D3 : use nest function to turn flat data with parent key into a hierarchy

我确信有一种非常简单优雅的方法可以做到这一点,但我不太明白。我有一些看起来像这样的输入数据:[{id:1,name:"Peter"},{id:2,name:"Paul",manager:1},{id:3,name:"Mary",manager:1},{id:4,name:"John",manager:2},{id:5,name:"Jane",manager:2}]如果可能,我想使用d3.js嵌套运算符来获取要在层次结构布局中使用的结构。像这样:[{name:"Peter",children:[{name:"Paul",children:[{name:"John"},{name:"Jan

javascript - .parents() 在 Angular 中?

有什么方法可以模拟jQuery的.parents()Angular中的方法,而不必实际包含jQuery?最终目标是获取DOM元素的所有父元素。编辑:为什么我需要这个?我正在创建一个指令(一个类似下拉的小部件)。下拉列表应收听整个对于点击并在小部件区域外进行点击时自行关闭(如果它打开)。现在,我知道如何创建一个简单的指令来监听鼠标事件,如下所示:app.directive('mouseTrap',function(){returnfunction(scope,elem){elem.bind('click',function(event){scope.$broadcast('click',