The instance does not define the property or method "message" but it is being referenced during rendering

** Check out the Screenshot Below:-** https://i.sstatic.net/u2UeW.png

Take a look at MessageComposer.vue:-

<template>
    <div class="composer">
    <textarea v-model="message" @keydown.enter="send" placeholder="Message..."></textarea>
    </div>
</template>


<script>
    export default {
    data() {
        return {
        messsage: ''                
            };
          },
        methods: {
            send(e) {
                e.preventDefault();
                if (this.message == '') {
                return;
    }

    this.$emit('send', this.message);
    this.message = '';
}
}
}   

</script>


<style lang="scss" scoped>
.composer textarea {
    width: 96%;
    margin: 10px;
    resize: none;
    border-radius: 3px;
    border: 1px solid lightgray;
    padding: 6px;
}
</style>

Let's Dive into Conversation.vue:-

<template>
<div class="conversation">
    <h1>{{contact ? contact.name : 'Select a Contact'}}</h1>
    <MessageFeed :contact="contact" :messages="messages"/>
    <MessageComposer @send="sendMessage"/>




</div>
</template>

<script>
    import MessageFeed from './MessageFeed.vue';
    import MessageComposer from './MessageComposer.vue';

    export default {
        props: {
        contact: {
        type: Object,
        default: null
},
        messages: {
            type: Array,
            default: []
}
},
    methods: {
        sendMessage(text){
            if (!this.contact) {
            return;
}
        axios.post('/conversation/send', {
        contact_id: this.contact.id,
        text: text
    }).then((response) => {
        this.$emit('new', response.data);
}) 
}

},

components: {MessageFeed, MessageComposer}

}

</script>


<style lang="scss" scoped>
.conversation {
    flex: 5;
    display: flex;
    flex-direction: column;
    justify-content: space-between;

    h1 {
        font-size: 20px;
        padding: 10px;
        margin: 0;
        border-bottom: 1px dashed lightgray;
    }
}
</style>

Lastly, Let's Take a Look at ChatApp.vue:-

<template>
    <div class="chat-app">
    <Conversation :contact="selectedContact" :messages="messages" @new="saveNewMessage"/>
    <ContactsList :contacts="contacts" @selected="startConversationWith"/>
     </div>
</template>

<script>
    import Conversation from './Conversation.vue';
    import ContactsList from './ContactsList.vue';
    export default {
    props: {
    user:{
        type: Object,
        required: true
}
},
        data() {
            return{
        selectedContact: null,
        messages: [],
        contacts: []
};

        },
    mounted() {

        axios.get('/contacts')
              .then((response) => {

        this.contacts = response.data;      
});

},
   methods: {
    startConversationWith(contact){
    axios.get(`/conversation/${contact.id}`)
        .then((response) => {
            this.message = response.data;
            this.selectedContact = contact;
})
},
    saveNewMessage(text){
        this.messages.push(text);
}
},
    components: {Conversation, ContactsList}

    }
</script>
<style lang="scss" scoped>
.chat-app {
    display: flex;
}
</style>

I've double-checked the codes and couldn't find any errors or mistakes, So, the issue might be something minor (apologies for that).

I've been stuck on this problem for quite some time now, I trust this information will help in resolving the error

I was simply following a tutorial and got stuck, Any assistance would be greatly appreciated

-Thank You

Answer №1

Within the MessageComposer.vue file, there is a mistake in the return data section.

return {
    messsage: ''  // There is a spelling error here. It should be message
},

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

Error detected in Deno project's tsconfig.json file, spreading into other project files - yet code executes without issues?

I am working on a Deno project and need to utilize the ES2019 flatMap() method on an array. To do this, I have created a tsconfig.json file with the following configuration: { "compilerOptions": { "target": "es5", ...

Node.js is indicating that the certificate has expired

When using Mikeal's request library (https://github.com/mikeal/request) to send an https request to a server, I keep encountering an authorization error of CERT_HAS_EXPIRED. request({ url: 'https://www.domain.com/api/endpoint', ...

Conditions are in an angular type provider with AOT

I am facing an issue with my Angular project that is compiled using AOT. I am trying to dynamically register a ClassProvider based on certain configurations. The simplified code snippet I am currently using is below: const isMock = Math.random() > 0.5; ...

Utilizing jQuery to extract the id and update its content

One of my tasks involves working with a table generated by PHP and incorporating a modal that allows users to change the text produced by the variable $l_id. I have a link with a class "eloc" that triggers the display of the modal div section. By intercept ...

A custom JavaScript function designed to replicate Excel's functionality of dividing numbers by thousands

I've noticed a unique behavior in Excel where when a cell is in focus and you enter, for example, 1500.32, it displays as 1 500.32. However, once you click enter or move away from the cell, it changes to 1 500.32. I'm intrigued by how this works. ...

Retrieving the contents of a unique 404 error page using ajax

Currently attempting to retrieve the content of a custom 404 page through ajax (I need to extract a counter value from this page using Greasemonkey). Regrettably, jQuery's .fail method in ajax does not provide the option to access the page's con ...

Vue.js has been identified on this specific page. Unfortunately, the Devtools inspection feature is not accessible as it is either in production mode or has been deliberately disabled by the author

https://i.sstatic.net/EWXLw.png I am attempting to activate vue-devtools in Google Chrome, but I am encountering some difficulties. The issue arises while trying to enable it within a Laravel application that utilizes Vue.js. https://i.sstatic.net/a7a4V. ...

Differences between importing Component and Vue from "vue-property-decorator" versus importing Vue from "vue"

Can you explain the specific differences and scenarios where importing Vue from vue-property-decorator versus just vue would be applicable? I have learned that when defining a custom component with a @Component decorator, it is necessary to import Vue fr ...

Prisma unexpectedly updates the main SQL Server database instead of the specified database in the connection string

I have recently transitioned from using SQLite to SQL Server in the t3 stack with Prisma. Despite having my models defined and setting up the database connection string, I am encountering an issue when trying to run migrations. Upon running the commands: ...

css background is repeating after the height of the div is reset

I'm working on a project where I want to resize an image while maintaining its aspect ratio to fit the height/width of the browser window. However, every time the code for resizing is implemented, the div height continues to increase with each resize ...

Is it possible to replicate the zoom text feature found in mobile browsers using selenium?

My automation script, which utilizes Selenium and Java on Sauce Labs, is presenting a challenge. I am struggling to find a JavaScript method or keyboard shortcut that can programmatically enable the 'Zoom text' function. Any advice or suggestions ...

JavaScript events are failing to trigger within the content area of an iframe

When attempting to run a given example by double clicking inside the content area of an iframe, the clicks and any JavaScript events are not being fired. Currently, the events can only be triggered by clicking on the border of the iframe, not inside the ...

Utilize JSON data fetched from a URL to dynamically populate an HTML content

There is a JSON file located at a URL that looks like this: [{"tier":"SILVER","leagueName":"Tryndamere's Wizards","queueType":"RANKED_SOLO_5x5","playerOrTeamId":"91248124", "playerOrTeamName":"NunoC99","leaguePoints":18,"wins":411,"losses":430,"rank" ...

Fixing the "Module not found" error in an Angular library using npm link

I'm currently working on creating an Angular wrapper for a Javascript library, but I've encountered a "Module not found" error. The Javascript library is still in development and has not been published to NPM yet. To work around this issue, I hav ...

Line numbers in Vue Codemirror

Currently, I'm working on integrating codemirror into my Vue.js application using a library found at https://github.com/surmon-china/vue-codemirror. The issue I'm facing is that even after importing and utilizing the codemirro component, everythi ...

Tips for displaying a detailed blog link in Angular

I am looking to display the details of a blog on a separate link in Angular. Within my Angular setup, I have a Blog file (blog.component.ts) and a service that retrieves all the blog data from an API backend created with Strapi. Each individual blog has a ...

Does aoMap function exclusively with THREE.BufferGeometry?

Can you provide guidance on setting up an aoMap for a standard THREE.Geometry object? Is there a demo available to reference? var uvCoordinates = geometry.attributes.uv.array; geometry.addAttribute('uv2', new THREE.BufferAttribute(uvCoordina ...

What steps can we take to create a personalized PDF editor incorporating our unique edit functionalities using Vue.js?

Is it possible to create a PDF editor similar to MS Word using vuejs? How can I implement custom logic in the PDF editor with vuejs? For example, the features should include: Conditional replacement of text Adding tags to text within the PDF Changing the ...

Ember controller failing to update template upon property set within promise execution

I am facing an issue while integrating user login functionality in my application. After retrieving the user data from the server, I aim to display the user's name on the page once the process is completed. The login form appears as a popup window, in ...

Optimal method for utilizing Babel to generate a unified JavaScript bundle

I have multiple JS files and I need to combine them into a single JS bundle using Babel. Someone pointed me towards this first resource, but I am having trouble grasping the instructions: https://babeljs.io/docs/usage/cli/ While searching online, I came ...