Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

287
Visualizações
Vue and firebase project giving mean error of Property or method "state " is not defined on the instance but referenced during render
<template>
<div>
  <div class="view login" v-if="state.username === '' || state.username === null">
    <form class="login-form" @submit.prevent="Login">
      <div class="form-inner">
    <h1>Login to FireChat</h1>
       <label for="username">Username</label>
       <input type="text" v-model="inputUsername" placeholder="Please enter your username...">
       <input type="submit" value="Login">
    </div>
    </form>

  </div>

  <div class="view chat" v-else>
    <h1>Chat View</h1>
  </div>
  
</div>
</template>

<script>
import { reactive, onMounted, ref } from 'vue';
import db from './db';


export default {
  setup () {
    const inputUsername = ref("");
    const state = reactive({
      username: "",
      messages: []
    });
    
    const Login = () => {
      if (inputUsername.value != "" || inputUsername.value != null) {
        state.username = inputUsername.value;
        inputUsername.value = "";
      }
    }

     return {
      inputUsername,
      Login,
      state
    }
  }
}
</script>

I cant seem to figure out where am getting it wrong when state is defined I believe. the screen shows nothing. this code is literally from a tutorial i watched and exactly this worked even after getting code from the tutorial github repo it still shows this error

Property or method "state " is not defined on the instance but referenced during render.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Never used vue but i noticed that your script declares state however your script is loaded in the document after the div is because of the order you placed it.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda