1
resposta

Property or method is not defined

Estou com esses erros no console e não sei como resolver.

[Vue warn]: Property or method "titulo" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property.
[Vue warn]: Property or method "foto" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property
vue.esm.js?efeb:628 [Vue warn]: Error in render: "TypeError: Cannot read properties of undefined (reading 'url')"

found in

---> <App> at src/App.vue
       <Root>

Código:

<template>
  <div>
    <h1>{{ titulo }}</h1>
    <img :src="foto.url" :alt="foto.titulo">
  </div>
</template>

<script>
export default {
  data() {
    return {
      titulo: 'Alurapic',
      foto: {
        url: 'https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcTwV4kVzT5McBdGSgqlVeRzubrNH_mOrrkKseDOGFURq20HmsrelEfMU7It',
        titulo: 'Cachorro',
      }
    }
  }
}
1 resposta

Olá, Ana, tudo bem?

O único problema é que faltou fechar a tag script, então basta escrever </script> ao final do código.