search

Home  >  Q&A  >  body text

Vue.js project error: Variable cannot be accessed before initialization

<p>I'm currently developing a Twitter clone using Vue 3. The source code for the same can be found here. </p> <p><code>HomeView.vue</code>The code is as follows:</p> <pre class="lang-html prettyprint-override"><code><template> <div class="home"> <Tweet v-for="tweet in tweets" :key="tweet._id" :tweet="tweet" /> </div> </template> <script> import { ref } from 'vue'; import Tweet from '../components/Tweet'; import tweets from '../tweets'; export default { setup () { const tweets = ref(tweets); return { tweets, Tweet } } } </script> </code></pre> <p>But after performing the same operation, I am getting the following error in the developer's console. </p> <pre class="brush:php;toolbar:false;">Uncaught (in promise) ReferenceError: Cannot access 'tweets' before initialization</pre></p>
P粉897881626P粉897881626463 days ago628

reply all(1)I'll reply

  • P粉020556231
  • Cancelreply