vue中动态加载事件的使用

parentMethods(myId) {
    
    
  var aObj = $("#myDiv");
  htmlStr += '<spa onClick="view('+"'"+myId+"'"+')" title="新增下一级">添加子规则</span>'+
      '<span onClick="edit('+"'"+myId+"'"+')">修改</span>'+
      '<span onClick="del('+"'"+myId+"'"+')">删除</span>';
  aObj.append(htmlStr);
},
view(id){
    
    
   alert('查看:'+id)
},
edit(id){
    
    
   alert('修改:'+id)
},
del(id){
    
    
   alert('删除:'+id)
},
...

created:function(){
    
    
  var that = this;
  window.view = that.view;
  window.edit = that.edit;
  window.del = that.del;
}

猜你喜欢

转载自blog.csdn.net/weixin_43222587/article/details/104777444