Vue.prototype.global={ polling:null, pollingIndex:0, timer:30000 } let str = window.location.href.substr(window.location.href.indexOf('?') + 1) let json = new Object() const arr = str.split('&') for(let i = 0; i < arr.length; i++) { let item = arr[i].split('=') json[item[0]] = item[1] } var mixin={ methods:{ connects1:function(gongneng,sql,flag,num){ $.post("../mysqlInsert/mysql.jsp", {"gongneng":gongneng,"sql":sql,'flag':flag,'anquanma':json["anquanma"]}, function(result){ if(num==1){ result=$(result).text(); index = result.indexOf("[["); if(index>-1){ if(result.indexOf("[[安全码异常]]")>-1){ //alert('请先登录后操作'); window.parent.location.href='../login/index.jsp'; }else{ result=result.substring(index).trim() alert(result); } }else{ alert(gongneng+"成功!") window.location.reload(); } } }) .fail(function(response) { alert('Error: ' + "服务器数据发生错误!"); return false; }); }, connects:function(gongneng,sql,flag,num){ $.ajax({ url :'../mysqlInsert/mysql.jsp', type : "post",//不局限于get data:{"gongneng":gongneng,"sql":sql,'flag':flag,'anquanma':json["anquanma"]}, async : true, success : function(result) { if(num==1){ result=$(result).text(); index = result.indexOf("[["); if(index>-1){ if(result.indexOf("[[安全码异常]]")>-1){ //alert('请先登录后操作'); window.parent.location.href='../login/index.jsp'; }else{ result=result.substring(index).trim() alert(result); } }else{ alert(gongneng+"成功!") window.location.reload(); } } }, error : function(data) { alert( 'Error: ' + "服务器数据发生错误!"+data); } }); }, } } //gongneng:自定义,sql存储过程,flag标志(0,是用张工之前功能插入,1存储过程查询,2存储过程插入),vals:vue里data参数 function loadAjxs1(gongneng,sql,flag,vals){ $.post("../mysqlInsert/mysql.jsp", {"yemian":"123","gongneng":gongneng,"sql":sql,'flag':flag,'anquanma':json["anquanma"]}, function(result){ if(flag==2){ result=$(result).text(); index = result.indexOf("[{"); if(index>-1){ result=result.substring(index).trim(); app.$data[vals]=JSON.parse(result); console.log(app.$data[vals]); }else if(result.indexOf("[[anquanmaerr]]")>-1){ //alert('请先登录后操作'); window.parent.location.href='../login/index.jsp'; event.preventDefault() } } }) .fail(function(response) { alert('Error: ' + "服务器数据发生错误!"); event.preventDefault() }); } function loadAjxs(gongneng,sql,flag,vals){ $.ajax({ url :'../mysqlInsert/mysql.jsp', type : "GET",//不局限于get data:{"yemian":"123","gongneng":gongneng,"sql":sql,'flag':flag,'anquanma':json["anquanma"]}, async : true, success : function(result) { result=$(result).text(); index = result.indexOf("[{"); if(index>-1){ result=result.substring(index).trim(); app.$data[vals]=JSON.parse(result); console.log(app.$data[vals]); }else if(result.indexOf("[[anquanmaerr]]")>-1){ //alert('请先登录后操作'); window.parent.location.href='../login/index.jsp'; event.preventDefault() } }, error : function(data) { alert( 'Error: ' + "服务器数据发生错误!"); } }); }