The value of Vue 2 custom components is consistently "null."

Attempting to design a customized component in Vue.

This basic component I have created seems to consistently have an undefined value prop.

<template>
    <div>
        - {{ value }} -
    </div>
</template>

<script>
    export default {
        props: ['value'],

        mounted() {
            console.log(this.value);
        }
    }
</script>

No special actions are taken when calling it:

<el-text-group v-model="testVar"></el-text-group>

{{ testVar }}

The variable testVar appears fine, but the custom component does not display anything?

I've gone through multiple tutorials and the official documentation:

https://v2.vuejs.org/v2/guide/components.html#Form-Input-Components-using-Custom-Events

Currently using Vue 2.4.2. Worked without issues on Vue 2.2.x.

This issue was encountered months ago, hoped for a fix, but upon retesting, the problem persists. Seems like a fundamental issue, uncertain if there has been a change in implementation?

FILES:

app.js

var component = require('./components/App.vue');

component.router = Vue.router;

new Vue(component).$mount('#app');

App.vue

<template>
    <div>
        Hello

        <hr/>

        <test-cpt v-model="testVar"></test-cpt>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                testVar: 'test'
            };
        },

        components: {
            testCpt: require('./TestCpt.vue')
        }
    }
</script>

TestCpt.vue

<template>
    <div>
        - {{ value }} -
    </div>
</template>

<script>
    export default {
        props: ['value']
    }
</script>

Answer №1

After deleting the node_modules folder and reinstalling, the issue was resolved.

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

Stop Vue bootstrap-dropdown from automatically closing upon clicking

Is there a way to modify the functionality of a b-dropdown-item-button in a b-dropdown-component so that it doesn't automatically close when clicked? This is the structure of the dropdown: <b-dropdown> <b-dropdown-item-button> ...

JavaScript code to retrieve and store data from API endpoints

I am working with a Web API endpoint that provides the location of a URL (). When a button is clicked, this API is called and a URL is returned. The file format could be PDF, Excel, or Word. I am looking for a way to download the file and save it to disk ...

Designing an interactive header interface using React and Material UI

My header.jsx file contains the following code: // Default Import Statements var Login = require(login.jsx) const HeaderComponent = React.createClass({ getInitialState () { return { loggedIn: false, }; }, render() { return ( ...

Customize GUI - adjusting menu dimensions and placement (javascript / css)

I’ve been experimenting with integrating Dat GUI into my Three.js project for adding some controls. The interface of Dat GUI really appeals to me, but I’m facing challenges in terms of positioning the menu on the page. Specifically, I’m looking to ce ...

How can I create an accordion panel that can be toggled using

I've been working on creating an accordion panel using CSS with a touch of JavaScript. Everything seems to be functioning correctly except for the toggling of the panels. Essentially, when one panel is clicked, I want all other open panels to close. ...

The behavior of React Router varies between local development on localhost and deployment on Heroku

Currently in the process of constructing a React-based website, initiated with create-react-app and incorporating react-router-dom`. The setup is as follows: index.js import React from 'react'; import ReactDOM from 'react-dom'; impor ...

I am facing an issue with Angular where the $http.get method is

It seems like there must be a small oversight causing this apparently simple problem. I have a function that interacts with the Spotify API to search for an artist. I know that by accessing the corresponding route using a standard URL, a result is returne ...

Storing JSON strings in PHP differs from storing them in JavaScript

Using JavaScript, I can save a cookie using JSON.stringify(), which saves the cookie directly like this: '[{"n":"50fb0d0cc1277d182f000002","q":2},{"n":"50fb0d09c1277d182f000001","q":1},{"n":"50fb0d06c1277d182f000000","q":1}] Now, I am sending this t ...

Struggling to meet PWA lighthouse test requirements even with service worker correctly installed

Recently, I've been diving into PWA development and I've encountered a roadblock. Despite successfully setting up my service worker and caching files, my app is not receiving the PWA mark for being installable when tested with Lighthouse. I' ...

Challenges with Angular scoping

I am facing an issue with a form in my ng-controller where it doesn't seem to update the properties in the controller as expected. After some research, I realized my misunderstanding of prototypal inheritance. Thanks to information from the internet a ...

After clicking, the radio button in Bootstrap 4 shifts to the left

I encountered an issue where the radio button I added to a table using Bootstrap 4 moves slightly to the left whenever I click on it. To better illustrate the problem, I have included a GIF below: https://i.sstatic.net/4aj8f.gif Below is the code for one ...

Vue project encountering TypeScript error: Module not found

In my Vue project, I am encountering an issue while using TypeScript. Whenever I try to import a .vue file, I encounter a 'cannot find module...' error. https://i.sstatic.net/jUPGe.jpg The strange thing is that the intellisense only displays t ...

What Could be the Reason Behind the Sharp Decline in My Google PageSpeed Insights Score?

Optimization On my desktop, I have successfully achieved a high page speed score of 96 on this site: https://developers.google.com/speed/pagespeed/insights/?url=https%3A%2F%2Fwww.usstoragecenters.com%2Fstorage-units%2Fca%2Falhambra%2F2500-w-hellman-ave&am ...

Display an empty string when a value is NULL using jQuery's .append() function

To set an HTML value using the .append() function, I need to include AJAX data values. If the data set contains a null value, it will show as 'null' in the UI. I want to remove that 'null' and display it as blank. However, I can't ...

Tips for inserting or updating inner objects within a JavaScript array

On my hands, I hold a JavaScript array structured like this: const Rooms = [{ name:"Science", students:[ {user:"Tom",emotion:"Happy"}, {user:"Marry",emotion:"Angry"}, {us ...

Extract the text located within a specific span using Selenium

Can anyone help me retrieve the value from the span tag in this scenario? The class name is consistent, but if there is an error in any of the fields belonging to that class, the text will become visible. For instance, consider the following two fields: ...

Customize a div's background color with an Angular directive

Imagine having a div element: <div id="wrapper"> some text </div> How can you create an angular directive that changes the background based on user input? For instance, you might have tried: <div id="wrapper" color temperature="51"> ...

Update ngx-datatable when the user clicks on a different directive

My issue involves a Side Navigation with a docking feature and a data table in the Main View. When I undock the side navigation, the data table does not recalculate automatically, leaving empty space where the Side Navigation was. This requires me to manua ...

Is it possible to delete a <div> tag based on screen size using jQuery or JavaScript?

Hello, I was curious if it's possible to dynamically remove a specific div tag using jQuery or JavaScript when the screen reaches a certain size, for example 500px. ...

"Anticipated an object value, yet got a string instead" utilizing slash commands in discord.js

I am in the process of developing an economy bot for Discord. I have completed the embeds and ActionRows for the transfer feature; however, when I attempt to run the /transfer command, I encounter the following error: Expected the value to be an object, b ...