我正在创建一个名册,其中的任务可以作出使用Vue。如果我给一个人分配一个特定的转换,那么他将被从所有的偏好中移除,我们将不再能够在不同的选项中导航。关闭将首选项向上移动1,而prev图标将其向下移动1,并勾选完成分配。看看代码小提琴。
现在,当完成分配时,执行删除操作。在那之后,整个Vue被更新。此删除操作禁用所有其他表cells.Why中的首选项列表导航,是否发生此禁用?有什么解决办法吗。另外,是否可以避免Vue武力更新?
$('.assign').click(function() {
app.assignNurse($(this));
app.$forceUpdate();
});发布于 2019-02-26 05:17:45
请在您的代码中更新下面一行。
$(document).on('click','.close',function() {
const curr = $(this).parent();
//console.log(curr.next());
curr.next().show();
$(this).parent().hide();
//$('.selection2').show();
//prevObj = curr;
});
$(document).on('click','.assign',function() {
console.log("ss");
app.assignNurse($(this));
});
$(document).on('click','.repeat',function(){
$(this).parent().hide();
//console.log($(this).parent().prev('div'));
$(this).parent().prev('div').show();
//$(this).parent().remove();
});之所以会出现问题,是因为您正在动态地创建元素,因此jquery事件无法处理动态创建的元素,因此您需要像这样编写单击事件。
这里是更新的小提琴链接,您可以在这里查看它的工作原理。
https://stackoverflow.com/questions/54878518
复制相似问题