What is the best way to showcase a message using if-else conditions in Vue.js?

<div class="dimension-section no-border-radius margin-top-2">
  <div class="dimension-size"></div>
  <div>
    <ul>
      <li v-on:click="display = !display" @click="getPartingCharges('5-10')" :class="{ active: isActiveClass, }" class="product-list">5-10 </li>
      <li @click="getPartingCharges('10-22')" :class="{  active: isActiveClass,}" class="product-list">10-22 </li>
      <li @click="getPartingCharges('22-27')" :class="{  active: isActiveClass, }" class="product-list">22-27</li>

    </ul> <span v-if="display">charges will be applied</span>
  </div>

</div>

When a user selects a quantity range like 5-10, 10-22, or 22-27 from the list of 3 li tags, a corresponding message needs to be displayed. If the user selects 5-10, then a message stating that charges apply should be shown. For selections of 10-22 or 22-27, a message stating that no charges apply should be displayed. This logic can be implemented using if else conditions.

Answer №1

<span v-if="display">fees will be incurred</span>
<span v-else>no fees will be incurred</span>

I'm not entirely sure what you're asking, but in Vue.js, you can utilize the if-else statement. If I am able to review your code, I will provide a more accurate response.

Additionally, it is advisable to use "display" as a master boolean value.

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

Steps for inserting a script tag in an Angular component

My Angular/Typescript website needs to integrate a third-party script that generates a table. However, I'm facing issues with rendering the table within the home.component.html file. I've managed to embed the script, but it doesn't seem to ...

Adding a class to an element in AngularJS

I have a question about entering empty values in an input field and highlighting its boundary. I added a new class 'warning' for this purpose and created the following code. HTML: `<body ng-app="TestPage"> <form ng-controller="TestFor ...

Switch the angular attribute by clicking on ng-click

I have a Google Map set up with markers that I need to switch on and off. <marker id='{{marker.id}} 'visible="{{ condition ? 'true' : 'false'}}"> </marker> Additionally, I have created a button to control the v ...

Oops! There was an unexpected error: TypeError - It seems that the property 'title' cannot be read because it is undefined

HTML document example <ion-header> <ion-toolbar color="danger"> <ion-buttons> <button ion-button navPop icon-only> <ion-icon ios="ios-arrow-back" md="md-arrow-back"></ion-icon> </button> ...

The jQuery keyup filter is functioning properly when the content is displayed in columns, but it is not working as expected when the

Encountering an issue where the boxes do not reset properly to a 2x4 layout after typing something into the input field (for example, "spore") and then deleting it. It seems to work when the boxes are placed into 4 columns, but when using float: left on #s ...

Managing the event of a browser/tab being closed in React using Javascript

Currently, I have implemented the beforeunload event handler in order to detect when the user closes the browser. However, when this event is triggered, a popup appears with options for 'leave' and 'cancel'. Is it possible to capture th ...

405 - Sorry, this method is not allowed for deletion

The issue at hand involves a Spring RESTful web service and a client. When attempting a DELETE request on the server, the following error is encountered: -> DELETE http://localhost:8080/employee/3/logout 405 (Method Not Allowed) Despite implementing th ...

What is the best method for animating a display table to none or reducing its height to

My goal is to animate a header whenever the class collapseTest is applied. After some trial and error, I have come up with the following solution: http://jsfiddle.net/robertrozas/atuyLtL0/1/. A big shoutout to @Hackerman for helping me get it to work. The ...

Local directory system for organizing users' files and folders

My website is built using mean-stack technology. I utilize the File System to create folders and write files on servers. Here is an example of the backend code: router.post('/httpOnly/mkdir', function (req, res, next) { var fs = require(&apo ...

Replace an NPM package with a completely different package

As per the official NPM documentation, utilizing the overrides feature in the package.json file allows for the substitution of a package with an entirely different one: Overrides serve as a means to swap out a package within your dependency hierarchy wit ...

Should developers avoid using jQuery in ReactJS applications?

While working on a ReactJS project (or any other project), I personally prefer using pure JavaScript over jQuery. Lately, I've started questioning whether it's considered bad practice to use jQuery in ReactJS. Back when I was learning ReactJS, I ...

Vue3 CLI constantly inquires about poor internet speed

While conducting an end-to-end test process, I set up Vue3 automatically using Vue CLI with the following command: npx --yes @vue/cli create vue3 --packageManager npm -n -i '{"useConfigFiles":true,"plugins":{"@vue/cli-plugin-b ...

Using JavaScript to implement word filtering in MongoDB

I'm currently in the process of creating a chatbot designed to filter questions, and I'm seeking guidance on how to refine the search in my MongoDb based on user input. At the moment, I have the following code: I aim to retrieve all the results ...

JavaScript For/in loop malfunctioning - Issue with undefined object property bug

Currently, I am tackling a basic For/in loop exercise as part of a course curriculum I am enrolled in. The exercise involves working with a simple object containing 3 properties and creating a function that takes two parameters - the object name and the it ...

The Motion of Rotating and Moving Items

Rotating and translating objects can be tricky. While you can successfully perform both actions, the challenge arises when rotating objects as their orientation gets lost -- causing the objects to move in the direction they are facing. if( keyboar ...

Concealing a message within a section that has been minimized to a width of 0

Recently, I've encountered a challenge in attempting to set the width of a section to 0 and have all its contents also disappear. Despite changing the section's width to 0px, the text inside continues to be displayed and even shifts off to the si ...

The HTML elements on the webpage are showing up incorrectly

When visiting thedaystaragency.com/home and scrolling down to our services section where the lightbulbs are located, it is apparent that they are misaligned and not functioning properly. I have provided the code that I am currently using, but I had to remo ...

`How can I retrieve data using PHP OOP and Vue.js together?`

I'm currently working on a project and facing a small issue. How can I retrieve records using PHP OOP with vue.js? Passing a variable in the URL within a class function seems to be challenging. I am utilizing Axios.js for sending AJAX requests. What a ...

Issue with 'for' loop iteration over object array

Can someone help me understand why I am getting the unexpected result "6 You have not watched undefined undefined" in the browser console when running this simple code? var films = [{ title: "The Mummy", hasWatched: true, stars: "5 stars" ...

Guide to utilizing the Array find method to retrieve an object in JavaScript

I'm currently working on a Homework assignment that involves passing a parameter called userID to an arrow function. Within this function, the task is to use the .find method on an array named users. This find function should retrieve an object contai ...