The router-link configuration does not translate into HTML code as expected

I have set up the Vue table header parameters as follows:

render: (h, params) => {

      return h(
        'router-link',
        {
          props: {
            tag: 'a',
            target: '_blank',
            to: {
              name: 'physicalserverDetails',
              query: {id: params.row.id}
            },

          }
        },
        params.row.name
      )
    }

However, upon checking the generated HTML code, it seems that the target parameter was not included:

<a href="/physicalserverDetails?id=193" class="">CD-Z12</a>

Do you see anything in my configuration that might be causing this issue?

Answer №1

In order to include normal HTML attributes like target, the vue.js documentation suggests passing them inside an attrs object. However, when target is defined as a prop in your code snippet, it cannot be included in the resulting anchor tag.

You can test the following code snippet:

render: (h, params) => {
  return h(
    'router-link',
    {
      attrs: {
       target: '_blank'
      },
      props: {           
        to: {
          name: 'physicalserverDetails',
          query: {id: params.row.id}
        }
      }
    },
    params.row.name
  )
}

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

Guide on how to send users to a personalized 404 page on remix.run

I'm having trouble redirecting the URL to a custom 404 page in remix.run. My URL structure looks like this - app/ ├── routes/ │ ├── $dynamicfolder/ │ │ ├── index.tsx │ │ ├── somepage.tsx │ │ ├ ...

Vue.js Pagination Issue - Current Page Number Beyond Maximum Page Limit

I'm currently working on incorporating pagination into a table showcasing data for Magic: The Gathering cards. By default, the table displays only 5 items per page, with options to select pages and set the number of results per page at the bottom of ...

Creating a dynamic JSTree that loads data on demand using Stored Procedures

Currently in my SQL Server database, I have two Stored Procedures that are responsible for extracting data from a tree structure: One procedure retrieves all nodes at a specific level based on the provided level number. The other procedure retrieves th ...

Utilizing State Variables Across Modules in ReactJS: A Guide

Having just started learning ReactJS, I am facing an issue with accessing the city_name variable in another module. Can anyone assist me with this problem? import { useState } from "react"; const SearchCity = (props) => { cons ...

Retrieving the value of a checkbox in a React custom checkbox component

I am facing an issue with my dynamic checkbox functionality. I need to update the state based on the selected options only, but my attempt to filter the state on change is not working as expected. Can someone help me identify what went wrong? const check ...

What is the optimal approach for setting up multiple routes for a single component in Vue router?

I have recently started learning Vue router and have set up the routes to navigate to the HomeView component like this: import { createRouter, createWebHistory } from 'vue-router' import HomeView from '../views/HomeView.vue' const rout ...

Error: Unable to access property 'camera' as it is undefined

After implementing the Raycaster from Three js to detect collision following a MouseMove event, I encountered an error: Cannot read properties of undefined (reading 'camera') Here is the code snippet causing the issue: bindIFrameMousemove(if ...

In the case that the parent contains a child class, consider using CSS or JQuery to conceal the second child class within the

Can you assist me in hiding the child element with the class of .secondchild within a parent element that has a child class? Below is the code snippet: HTML code <div class="parent"> <div class="child"> children </div> ...

Encountered issue with Ajax post request without any additional details provided

I could really use some assistance with this issue. It's strange, as Chrome doesn't seem to have the same problem - only Firefox does. Whenever I submit the form, Ajax creates tasks without any issues. My MySQL queries are running smoothly and I& ...

The transfer of variables from AJAX to PHP is not working

My attempt to pass input from JavaScript to PHP using AJAX is not successful. I have included my JS and PHP code below: <!DOCTYPE html> <html> <head> <style> div{border:solid;} div{background-color:blue;} </style> </head&g ...

Ways to display or conceal an input based on the chosen option in a select input?

When selecting option 2 in a dropdown list, I want an additional input field to be displayed. As a beginner in Vue.js, I'm unsure of the best approach to achieve this. Should I use an onchange event listener or is there a different method? The data sh ...

Retrieving information from a MySQL database to incorporate into D3 for the purpose of generating a line chart

I am looking to utilize D3 for data visualization by creating graphs based on the data stored in a MySQL database that I access through Python/Django. There are two approaches I have come across to achieve this: Creating arrays of dictionaries with x and ...

What is the logic behind the code returning the odd number in the array?

Can anyone clarify why the result of the following code is [1,3]? [1,3,6].filter( item => item % 2) I anticipated getting the even numbers from the array. Thank you for your help! ...

``Enhanced feature allowing users to input different zip codes in a weather

Currently, I am exploring the integration of a weather plugin found at: http://jsfiddle.net/fleeting/a4hbL/light/ The plugin requires either a zipcode or woeid to function. Instead of hardcoding the zipcode, I am looking to make it dynamic so that users f ...

What is causing the PHP AJAX MySQL Chat Script to require a page refresh?

Seeking assistance with a chat script I developed using AJAX to insert data without page refresh. Although the data inserts successfully, I encounter the issue that a page refresh is required in order to view the newly inserted data. My implementation util ...

Extract JSON data from a web address

Currently in the process of creating a website, and I am utilizing a URL that gives back a JSON response structured like so: {name:mark; status:ok} My goal is to extract just the name using JavaScript or jQuery exclusively within my HTML page. Could any ...

The menu starts off in the open position when the page loads, but it should remain closed until it

I'm having trouble with my menu; it displays when the page loads but I want it to be closed and then open when clicked. Despite my best efforts, I can't seem to fix this issue. <html> <head> <script> $(document).ready(funct ...

JS API call returns an undefined variable

I am trying to access the dataValues section of a JSON object returned by a function that is invoked through an API call: exports.findOne = (req, res) => { const id = req.params.id; Users.findByPk(id) .then(data => { if(d ...

Unable to sign out user from the server side using Next.js and Supabase

Is there a way to log out a user on the server side using Supabase as the authentication provider? I initially thought that simply calling this function would work: export const getServerSideProps: GetServerSideProps = withPageAuth({ redirectTo: &apos ...

What would be the JavaScript counterpart to python's .text function?

When using Element.text, you can retrieve the text content of an element. Recently, in a separate discussion on SO, there was a Python script discussed that scraped data from the followers modal of an Instagram account. The script is designed to capture t ...