草庐IT

property-binding

全部标签

带有绑定(bind)点击事件的 Javascript 循环总是返回最后的结果

我有一个在javascript中运行的for循环。在这个循环中,我创建了一个列表项并将点击事件绑定(bind)到它。当我单击此列表项时,我希望它以当前循环对象中的数据作为参数调用一个函数。问题是,无论我点击哪个列表项。作为参数传递的数据是我正在循环的对象的最后一个元素,而不是正在单击的当前元素。for(eindata){varsuggestItem=$(''+data[e]['name']+'');suggestItem.click(function(){$(this).addClass('activeSuggestion');suggestSelect(suggestField,da

javascript - 将键盘绑定(bind)到左/右导航

我是一名摄影师,我有一个网站,我无法在其中编辑"template"结构,但可以上传javascript/css等。我想将下一个/上一个导航绑定(bind)到键盘右/左。链接的结构是:ImageNavigationIndexPreviousNext我提到了this并设法创造了这个。$(function(){$(document).keyup(function(e){switch(e.keyCode){case37:window.location=$('li.prev').attr('href');break;case39:window.location=$('li.next').attr

javascript - 脚本 438 : Object doesn't support property or method 'debug'

我试图搜索这个但无济于事。我拥有的代码是由网站上一个非常好的人提供的,然后我修改了属性以使我适合的元素适合他们需要去的地方,但是,在所有浏览器中一切正常,也就是说,除了IE-漂亮很多版本。我在IE9中运行调试并得到这个错误“SCRIPT438:Objectdoesn'tsupportpropertyormethod'debug'它引用的代码段是这样的functionresizeContent(){//RetrievethewindowwidthvarviewPortWidth=$(document).width();varviewPortHeight=$(document).heigh

javascript - 未捕获的类型错误 : Cannot read property 'name' of undefined

单击“选择文件”时,我有以下代码:$(':file').change(function(){if(this.files.length==1){$('#selected_files').html("Attaching"+this.files.length+"file");}else{$('#selected_files').html("Attaching"+this.files.length+"files");}$('#selected_files').append("FilenameSize");for(x=0;x"+name+"("+filesize(size)+")"+type+"

javascript - CKEditor 4 : Uncaught TypeError: Cannot read property 'langEntries' of null

我正在为CK编辑器(https://github.com/galetahub/ckeditor)使用Rubygem,但出现此错误:UncaughtTypeError:Cannotreadproperty'langEntries'ofnull这是它在代码中出现的地方:CKEDITOR.plugins.load=CKEDITOR.tools.override(CKEDITOR.plugins.load,function(a){vard={};returnfunction(b,c,e){vari={},g=function(b){a.call(this,b,function(a){CKEDI

javascript - 未捕获的类型错误 : Cannot read property 'getContext' of null

在我的控制台中,我收到错误:“未捕获的类型错误:无法读取null的属性‘getContext’”我就是找不到我犯的错误……或者我做错了什么。那么也许你可以帮我找到它?请帮助:)entercodeherevarcanvas=document.getElementById("myCanvas");varctx=canvas.getContext("2d");varcW=canvas.width=1000;varcH=canvas.height=500;varparticleAmount=10;varparticles=[];for(vari=0;i 最佳答案

javascript - Angular 2 : How to pass down a template through a component property?

如何在Angular2中通过组件属性传递模板?我只做了第一步:@Component({selector:'tab',template:`#!HEREGOESTHEHEADERTEMPLATE!#`})exportclassTab{@Input()title:string;@Input()headerTemplate:string;...可以这样使用:{{title}}'">SomeContent应该呈现:SomeTitleSomeContent此时我卡住了。 最佳答案 虽然这个问题很老,但有更好的解决方案。无需将字符串作为模板传递-

javascript - bind 和 var self=this 的区别?

在我的Reactnative代码中,我在多个模块的多个位置同时使用了bind(this)和varself=this;。两者都解决了在正确位置解析this关键字的问题。这是我的代码(执行相同功能的2个代码)-使用bind(this)retval.then(function(argument){console.log("argument"+JSON.stringify(argument));this.stateSetting(argument);}.bind(this));使用varself=thisvarself=this;retval.then(function(argument){c

javascript - Vue.js 'v-bind:class' 不更新,即使模型更新

我有一个项目列表,我想对当前选定的项目应用一种样式。我也在使用Vuex来管理状态。我的列表组件:constList=Vue.component('list',{template:'0">'+''+'{{g.text}}'+''+''computed:{items:function(){returnthis.$store.state.items;}},methods:{selectItem:function(index){this.$store.commit('selectItem',index);}}});我的商店:conststore=newVuex.Store({state:{it

javascript - Controller 内部的 Angular 1.6 绑定(bind)

我试图通过绑定(bind)将一些参数传递给我的组件,但不幸的是我没有在我的Controller中使用这些参数,这是我的代码:angular.module('project1').component('menu',{templateUrl:'/static/js/templates/menu.template.html',bindings:{rid:'@'},controller:['Restaurant',functionRestaurantListController(Restaurant){console.log(this.rid);console.log(this);this.r