Issue with Nuxt: Property accessed during rendering without being defined on the instance

As I attempt to create cards for my blog posts, I encountered an issue with a Post component in my code. The cards are displaying like shown in the picture, but without any text. How do I insert text into these cards? Currently, all the text is within attributes. Vue and Nuxt examples I've looked at don't seem to be helpful.

[Vue warn]: Property "title" was accessed during render but is not defined on instance.
[Vue warn]: Property "date" was accessed during render but is not defined on instance.
[Vue warn]: Property "text" was accessed during render but is not defined on instance.
...
<template>
    <div class="post"><div><b>{{ title }}</b></div><div><small><i>{{ date }}</i></small></div><div>{{ text }}</div></div>
</template>
export default Vue.component('Post', {
    props: {
        id: number,
        date: Date,
        title: string,
        text: string
    }
});
<script setup lang="ts">
import Post from '~/components/Post.vue';

let posts = [
        {
            id: 1,
            date: new Date(),
            title: 'Title1',
            text: 'Lorem ipsum dolor sit amet'
        },
        {
            id: 2,
            date: new Date(),
            title: 'Title2',
            text: 'Lorem ipsum dolor sit amet'
        },
        ...
</script>
<template>
<div class="posts">
    
</div>
<Post  
        v-for="post in posts"
        :key="post.id"
        :title="post.title"
        :date="post.date"
        :text="post.text"
    ></Post>
</template>

I've tried various script forms in components, but nothing seems to work as expected.

Answer №1

When creating a component in Vue3/Nuxt3, it is recommended to utilize the defineComponent helper for proper syntax:

<template>
    <div class="post"><div><b>{{ title }}</b></div><div><small><i>{{ date }}</i></small></div><div>{{ text }}</div></div>
</template>
<script lang="ts">
import {defineComponent} from "vue"

export default defineComponent({
     props: {
        id: Number,
        date: Date,
        title: String,
        text: String
    }
})

</script>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Angular Checkbox Binding Issue Detected

Struggling with a problem related to an Angular checkbox form that is generated from an API. I am able to create checkboxes, but encountering two issues: The checked state of the boxes does not align with the values retrieved from the API, and when I clic ...

Receive a notification for failed login attempts using Spring Boot and JavaScript

Seeking assistance with determining the success of a login using a SpringBoot Controller. Encountering an issue where unsuccessful logins result in a page displaying HTML -> false, indicating that JavaScript may not be running properly (e.g., failure: f ...

Error: Uncaught [🍍]: The function "getActivePinia()" was invoked without an active Pinia instance present. Ensure that you have called "app.use(pinia)" before attempting to utilize a store

I encountered an issue while trying to access a store in Pinia for my Vue web application. Despite installing Pinia and setting app.use(createPinia()), I keep receiving the following error message: Uncaught Error: [ ...

How can I create a reverse animation using CSS?

Is there a way to reverse the animation of the circular notification in the code provided? I want the circle to move forward, covering up the info and fading out. I've tried switching the animation around but haven't had success. Any suggestions? ...

Creating a multi-level mobile navigation menu in WordPress can greatly enhance user experience and make

Hey there, I am currently in the process of developing a custom WordPress theme and working on creating a mobile navigation system. Although I have managed to come up with a solution that I am quite pleased with after multiple attempts, I have encountered ...

Combining Angular with X3D to create a seamless integration, showcasing a minimalist representation of a box

I am brand new to web development, and I am feeling completely overwhelmed. Recently, I decided to follow the Angular tutorial by downloading the Angular Quickstart from this link: https://github.com/angular/quickstart. My goal was to add a simple x3d ele ...

Refresh all fields for various products with a single click of a button

Our Magento multi-vendor site allows vendors to easily manage their products. For each single product, vendors can view and update information such as price, selling price, quantity, and more from their vendor account. We have implemented a feature where ...

Deactivate every checkbox in a row within an array

Seeking assistance with disabling a specific checkbox within a row. For example, Consider the following scenario {availableBendsHostnames?.map((bEnds, indx) => ( <div key={indx}> <div>B-End: {bEnds}</div> ...

NextJS does not support the rendering of the map function

Currently, I am getting acquainted with NextJS by creating a basic blog. I have successfully passed the data through props and can see it logged in the console within the map function. However, I am facing an issue where the HTML content does not display i ...

Whenever I execute my code, the browser consistently crashes

Here is the code I have been working on: var images = ["image1.jpg", "image2.jpg", "image3.jpg", "image4.jpg", "image5.jpg", "image6.jpg", "image7.jpg", "image8.jpg"]; var objects = []; var geometry; while(objects.length < images.length) { va ...

Recover Checkmark Status from Data

Currently, I am storing form data in json format and encountering an issue when trying to load values from a previously created json file. The plain old JavaScript function provided below successfully loads values into a form from a file, effectively resto ...

Eliminate items/attributes that include a certain term

Is there a way in Node.js to remove all fields or objects from a JSON file that have a specific word (e.g. "test") as their name, and then return the modified JSON file? Take a look at an example of the JSON file: { "name": "name1", "version": "0 ...

Steps for adjusting the length in the getRangeLabel function of mat paginator

@Injectable() export class MyCustomPaginatorIntl extends MatPaginatorIntl { public getRangeLabel = (page: number, pageSize: number, length: number): string => { if (length === 0 || pageSize === 0) { return `${ ...

Guidelines for sending data as an array of objects in React

Just starting out with React and I have a question about handling multi select form data. When I select multiple options in my form, I want to send it as an array of objects instead of an array of arrays of objects. Can anyone help me achieve this? import ...

What could be causing my recursive function to skip over certain parts of my JSON data?

UPDATED TO BE MORE CONCISE Hello, I'm looking for assistance with a recursive function that's not returning the expected values from a JSON object. The goal is to retrieve all "Flow" object IDs where the "Type" is either "Standard" or "Block". T ...

UI-Router: What is the best way to access a page within my project without adding it as a State?

Currently in the process of learning Angular and UI-Router. Initially, I followed the advice of many and chose to utilize UI-Router. In my original setup, the login page was included in all States. However, I decided it would be best to keep it as a separ ...

"Implementing a loading function on a particular div element within a loop using

Hey everyone! I'm new to this forum and have recently made the switch from jQuery to Vue.js - what a game-changer! However, I've hit a little snag. I need to set v-loading on multiple buttons in a loop and have it start showing when clicked. Her ...

Switch between dropdowns with jQuery

Issue at Hand: In the scenario illustrated below, there is a side navigation bar containing options that reveal a toggled section upon clicking. Specifically, if you select the third item labeled "Dolar" from the menu, a dropdown with three additional cho ...

Paste the formatted text from clipboard into the body of a react mailto link

I have a requirement for users to easily send a table via email by copying and pasting it into the subject line. You can view a live demo of this feature on CodeSandbox: copy and paste rich text Below is the function that allows users to copy and paste ri ...

extract data from a JavaScript object

Currently facing an issue extracting a String name from the JSON object's name. It is necessary to parse this type of JSON response obtained from the server. var response = { hopaopGmailsjIpW: { GmailsjIpW_totalEmails_count: 133, GmailsjIpW ...