我已将类定义为:
//Las propiedades de un botón
class propiedadesDeBoton {
propiedadesDeBotonconstructor(botonActual, nombreBoton, pathBorde, pathDibujoDeFondo,
stateButton, lastStateButton, toggleButton) {
this.botonActual=botonActual; //El botón;
this.nombreBoton; //El nombre del botón;
this.pathBorde=pathBorde; //El borde
this.pathDibujoDeFondo=pathDibujoDeFondo; //El dibujo del botón
this.stateButton=stateButton; //El estado actual del botón
this.lastStateButton=stateButton; //El estado actual del botón
this.toggleButton=toggleButton; //Si es tobbleButton o no
}
}
这个类定义在Firefox,Chrome和Opera中没有问题。
当我尝试在IE11中运行时,代码崩溃了。我可以在onload函数中找到错误
<?xml version="1.0" encoding="utf-8"?>
<svg version="1.1" id="project" xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
onload="init(evt)"
>
我删除了这个类定义,代码没有崩溃。
问题是:IE的类定义中是否有任何错误?
感谢
答案 0 :(得分:0)
我要回应自己。 实际上,IE11和Opera不支持类定义。
我找到的唯一方法是构造一个矩阵。我明白这不是最好的方法,但是......
微软和苹果,这个年份......
function botonDeBotonera(boton,nombreBoton,stateButton,lastStateButton,
toggleButton,pathBorde,pathDibujoDeFondo,rel) {
this.botonActual=boton; //El botón actual (viene de parámetro de función)
this.nombreBoton=nombreBoton; //El nombre del botón actual
this.stateButton=stateButton; //El estado actual del botón
this.lastStateButton=lastStateButton; //El estado anterior del botón
this.toggleButton=toggleButton; //Si es tobbleButton o no
this.pathBorde=pathBorde; //El borde
this.pathDibujoDeFondo=pathDibujoDeFondo; //El dibujo del botón
this.rel=rel;
}
var botonera=[];
function setPropiedadesDeBotones(botonActual,nombreBoton,stateButton,lastStateButton,
toggleButton,pathBorde,pathDibujoDeFondo,rel) {
var botonActual=botonActual; //El botón actual (viene de parámetro de función)
var nombreBoton=botonActual.getAttribute("id"); //El nombre del botón actual
var stateButton=botonActual.getAttribute("buttonstate"); //El estado actual del botón
var lastStateButton=botonActual.getAttribute("laststate"); //El estado anterior del botón
var toggleButton=botonActual.getAttribute("togglebutton"); //Si es tobbleButton o no
var pathBorde //El borde
var pathDibujoDeFondo //El dibujo del botón
for (var i=0;i< botonActual.childNodes.length;i++) {
try {
var pathVolatil="";
pathVolatil=botonActual.childNodes[i];
var idVolatil=pathVolatil.getAttribute("id");
if (idVolatil.indexOf("borde")!=-1) {
pathBorde=pathVolatil;
} else if (idVolatil.indexOf("dibujo")!=-1) {
pathDibujoDeFondo=pathVolatil;
}
} catch(err) {}
}
botonera.push(new botonDeBotonera(botonActual,nombreBoton,stateButton,lastStateButton,toggleButton,pathBorde,pathDibujoDeFondo,[]));