Having difficulty with closing a modal using v-model in VueJS

Upon pressing the button labeled Close, an error message appeared in the console as shown below:

"Error: Cannot find module './undefined'"

found in

---> <WhatsNew> at src/components/WhatsNew.vue 

Displayed below is the content of WhatsNew.vue:

<template>
  <u-modal v-model="modalActive">
      ......
      ......
      <div class="whats-new-options">
        <div id="whats-new-checkbox">
          <u-checkbox v-model="whatsNewStatusInactive" label="Don't show again"/>
        </div>
        <div id="whats-new-next-button">
          <u-button id="whats-new-close-btns" full color="secondary" @click="nextNew">{{notViewedAll ? 'Next' : 'Close' }}</u-button>
        </div>
      </div>
    </div>
  </u-modal>
  
</template>
<script>
  import { mapGetters, mapMutations } from "vuex";
  export default {
    data() {
      return {
        modalActive: false,
        notViewedAll: true,
        newFeaturesOnUsedCount: 3,
        current: 0,
      }
    },
    methods: {
      ...mapMutations("client", ["updateWhatsNewStatus"]),
      nextNew() {
        if (this.current <= this.newFeaturesOnUsedCount -1 ){
          this.current += 1
        }
        if (this.current >= this.newFeaturesOnUsedCount && !this.notViewedAll) {
          this.modalActive = false
        }
        
        if (this.current >= this.newFeaturesOnUsedCount - 1) {
          this.notViewedAll = false
        }
        
      }
    }

An attempt to resolve the error was made by adjusting:

<u-modal v-model="modalActive">

to

<u-modal v-model="modalActive" v-if="modalActive">

Although using v-if to manage the modal felt like a workaround. The original use of v-modal should have sufficed. What could be causing the aforementioned error? Your insights are appreciated.

Answer №1

Consider utilizing v-show in place of v-model for better performance.

<u-modal  v-show="modalActive">

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

At times, Vue.js may encounter difficulties when attempting to load a component

Recently, a strange issue has been occurring in my production code. Although nothing has been changed, I am now receiving reports that occasionally a template fails to load causing the page to crash. I am currently using vue 2.16. The error messages being ...

Issue encountered while compiling ReactJs: Unexpected token error found in App.js

I executed the commands below. npx create-react-app github-first-app npm install --save react-tabs npm i styled-components npm install git-state --save using the following code files App.js import React from "react"; import Layout from " ...

Refresh the view when the URL is modified

Utilizing angularjs alongside ui-router (using the helper stateHelperProvider) to organize views and controllers on the page. Encountering an issue where the views are not updating as expected. The relevant code snippet config.js app.config(function($h ...

Refreshable div element in a Code Igniter-powered web application

I am encountering difficulties with automatically refreshing my div using the CodeIgniter framework. My goal in the code snippet below is to have the particular div with id="lot_info" refresh every 1 second. The div is not refreshing, and an error message ...

Execute the Selenium function repeatedly using values from an array in a loop

I am facing a challenge with running a selenium script in a loop to populate a database. I have an array of objects consisting of 57 items that need to be processed through the loop asynchronously. My goal is to iterate through each store, check its status ...

Is there a way to exclude certain URLs from the service worker scope in a create react app, without the need to eject from the project?

Is there a way to remove certain URLs from a service worker scope in create-react-app without needing to eject? The service worker is automatically generated, and it seems impossible to modify this behavior without undergoing the ejection process. ...

Implementing Cors in Laravel 5.6 using Passport for authentication and Vue.js with Axios for making API calls

After extensive research on solving my CORS problem, I came across this package that promised to resolve everything. However, despite my attempts to implement it, I have yet to find a solution. The error I'm encountering is: Failed to load https://b ...

Empty Angular-chart.js Container

How can I resolve the issue of getting a blank div and no output while trying to display a chart where the options, labels, and other data are initialized in the TypeScript controller and then used on the HTML page? I added the angular-chart.js library us ...

What is the method for sending one URL as a parameter within another URL?

When I try to access the route /new/:url with a request like /new/https://www.google.com, the response is Cannot GET /new/https://www.google.com. What I actually want to receive is the string https://www.google.com. I came across an answer on URL compone ...

Having difficulty extracting data from certain tables with Beautiful Soup

I have been utilizing BeautifulSoup for data scraping from the website here. Although there are a total of 9 tables with the same class name, I am only able to extract information from 5 of them. What modifications should I implement in my code to ensure t ...

Restrict Vue Router access to specific pages only

Once a user has logged in for the first time, they are directed to the CreateProfile page where they can enter their profile information. I want to restrict access to this page so that if the user manually types the URL into their browser (e.g. www.myproje ...

Encountering the error message "Unable to access /" on the browser when using express router

Just started working with the express Router for the first time. Here is my route.js: var express = require('express'); var router = express.Router(); router.get('/', function(req, res) { res.send('home page'); }); module.e ...

What is the best way to integrate an admin template into a website without relying on popular CMS platforms like WordPress?

Do I need to use a WordPress system in the backend in order to utilize an admin template? I've noticed that there are several sleek web admin templates available in Bootstrap. I'm interested in using one of them but unsure how to do so without re ...

The selection in one dropdown menu influences the options in another dropdown menu

My partner and I have teamed up to develop a React translation application that utilizes the Lexicala API. Our project includes two selector components: one for choosing the source language and another for selecting the target language. Users will first pi ...

Creating HTML elements using Vue.js

Currently, I am facing an issue while attempting to render a template using the push mutation method. My goal is to push a section component, but instead of seeing the desired template content on my page, I am only getting the raw output of <vsection> ...

The parameters in VueJS are malfunctioning on this webpage

I created my vue in an external file and included it at the bottom of my webpage, but I am encountering issues with its functionality. One specific problem arises when using v-model, resulting in a template error displayed on the page: Error compiling t ...

Expanding the use of tagged template literals for passing additional arguments

Currently, I am utilizing styled-components and creating components through their tagged template literal syntax like this: const Button = styled.button` background-color: papayawhip; border-radius: 3px; color: palevioletred; ` In a specific scenar ...

Exploring the Scope of HTML Element IDs within Vue Components

Does Vue provide a built-in scoping mechanism for components so that the id attribute values of HTML elements inside each component are automatically unique? In the code snippet below, I have created two components and expected them to behave independentl ...

What methods can I use to prevent caching of XMLHttpRequest requests without relying on jQuery?

I am currently working on a web application that refreshes a table every minute from an XML file. However, I have noticed that when I make edits to the content of the XML file, I see a "304 Not Modified" message in the script log when trying to retrieve th ...

Can a Stylus and Node.js with Express project utilize a local image?

Let's talk about using images in a Web app. In my Stylus file, style.styl, I typically set the image using code like this: .background background: url(http://path/to/image) But what if we want to save the image to our local app directory and use ...