javascript is not being loaded in the mobile browser

Asked

Viewed 39 times

-2

I’m having a weird problem in my javascript, when I run in the pc browser works normal, but when I run in the mobile browser javascript does not recognize my functions/variables.

class UusarioDAO{
    static async trazDadosUsuario(id){
        const dados = await 
        firebase.database().ref("usuarios/"+id).once("value");
        usuario.setUsuarioId(dados.val().usuarioId);
        usuario.setNome(dados.val().nome);
        usuario.setPais(dados.val().pais);
        usuario.setFoto(dados.val().foto);
        usuario.setEmail(dados.val().email);
        usuario.setFotoProvedor(dados.val().fotoProvedor);
        usuario.setCaminho(dados.val().caminho);
        usuario.setToken(dados.val().token);
        usuario.setUsuarioGostos(dados.val().gostos);
        pais = dados.val().pais;
        return new Promise((resolve,reject)=>resolve("resolvido"));
    }
}
class EventoDAO{
    static async listar(id){

        let eventos = [];

        const eventosRef = firebase.database().ref("eventos/"+pais);


        try{
            const user = await userRef.once("value");

            const categorias = await eventosRef.once("value");
            categorias.forEach(auxEvento=>{
                const evento = new Evento();
                evento.setId(auxEventos.val().id);
                evento.setTitulo(auxEventos.val().titulo);
                evento.setDescricao(auxEventos.val().descricao);
                evento.setHorario(auxEventos.val().horario);


               eventos.push(evento);
           });



        return new Promise((resolve,reject)=>resolve(eventos));

        }catch(erro){

            console.log(erro);

            Notificacao.erro(erro);

         }
    }

 }
try{
    await UsuarioDAO.trazDadosUsuario(user.uid,null);
    const eventos = await EventoDAO.listar(user.uid);
    escondeLoading()

    eventos.forEach(evento=>{

        criaLista(evento,"todos");

    });    

    defineLanguage();
    if(navigator.language.split("-").shift()=="en"){
        $(".btn-success").css("padding","30px 30px");
        $(".btn-primary").css("padding","30px 8px");
    }
}catch(erro){
    console.log(erro);
    Notificacao.erro(erro);
}

}

como mostra no pccomo mostra no celular

  • you have defined the class name Uusariodao and are using Usuariodao, you realize that there is a u the most

  • It was a mistake just here in question. in my code not so ta not, but the problem is that it works in the normal browser, but when I try by mobile will not. the link if you want to test on your https://apptcc-6f556.firebasepp.com/eventos.html

  • It’s not a weird problem, rs. What happens is that you are using newer javascript features without before building in the stable version. In short, you are utilizing class as if it were something standard in all browsers, but unfortunately it is not yet. If you want something crossbrowser, you will need to transpose your code with Babel or some other Compiler. Abs

  • did not understand, because I tested on pc Chrome and cell phone Chrome also, but it did not work

1 answer

1


Boom diaa!

Well, you’ll probably be using or already using Cordova to be able to run this site as an App in a Web View. One of the things you have to pay attention to is the version of Ecmascript used and the version of both browsers, both mobile and pc. Your code is using Javascript version ES6, so you don’t have a compatibility problem, you need to convert to ES5 using Babel.

An example of the implementation of Babel, you can see in this link. How to Convert ES6 into ES5 using Babel

You can use this online code coverter, to make tests, in this link.

Babel Online

  • guy is that same, I use the Cordova, this Babel is very interesting, but it did not solve my problem, but I tested in the android browser without using this Babel and it worked, so I think the problem ta on IOS

Browser other questions tagged

You are not signed in. Login or sign up in order to post.