Embedding HTML Tags within an array element

The task at hand involves adding an HTML element from Array Value to the Document Object Model

template: {
    0: {
       h1: '<h1>Hi</h1>'
    },
    1: {
       h2: '<h2>Hi</h2>'
    },
    2: {
       h3: '<h3>Hi</h3>'
    }
}

I am utilizing a VueJS For Loop:

        <div v-for="temp in template">
            {{ temp.h1}}
        </div>

Resulting DOM :

<h1>hi</h1>

Answer №1

You might want to consider using the v-html binding to insert raw HTML into the page.

Here is an example:

<div v-for="temp in template">
    <div v-html="temp.h1">
</div>

For more information, you can check out this link: https://v2.vuejs.org/v2/guide/syntax.html#Raw-HTML

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

Refreshing express-session sessions

My goal is to enhance the user experience by retrieving their profile from the mongodb database when they visit the page, and then updating their session with this information. Currently, I am utilizing the following packages for managing sessions: - ex ...

The addClass() method seems to be malfunctioning following an ajax request

My current project involves setting up an AJAX call that is triggered when a user clicks on an anchor link. Once the AJAX operation is successful, I want to dynamically add a class to the specific anchor that initiated the call. The script itself seems to ...

Resolving CORS issues: Troubleshooting communication between a React app and an Express server

After successfully running both the app and server locally, I encountered an issue upon deploying the express server. Whenever I try to make a request, I consistently receive the following error message: "has been blocked by CORS policy: Response to ...

"Utilize jQuery to load a file when hovering over a specific

How can I dynamically load an external file using jQuery when a user hovers over a specific div? I attempted to load the file like a CSS file on hover but was unsuccessful. Is it possible to load a CSS file on hover as I've seen in some examples? $(d ...

Having trouble understanding why the other parts of my header are not displaying

<head> This special function runs when the webpage is loaded. <body onload="myOnload()"> A distinctive div at the top with a unique graphic <div id="header"> <img src="resumeheader.png" alt="Header" style="width:750px;h ...

"Send the selected radio button options chosen by the user, with the values specified in a JSON format

My current task involves inserting radio button values into a MySql database using Angular. The form consists of radio buttons with predefined values stored in a json file. Below is an example of how the json file is structured: //data.json [{ "surve ...

Error in Python: A scalar index can only be created from integer scalar arrays

I encountered an issue when compiling a program in Python that resulted in a TypeError: only integer scalar arrays can be converted to a scalar index. Despite what seems like a straightforward program, I am struggling to resolve this error. Frequency im ...

New update in Next.js version 13.4 brings a modification to routing system

I'm currently working with Next.js 13.4 and an app directory. I'm trying to implement a centrally located loader that will show whenever there is a route change anywhere within the app. Since routes/navigation don't have event listeners, I&a ...

My code seems to be malfunctioning - why can't I keep the aspect ratio?

UPDATE: Can someone please assist me with maintaining the aspect ratio of a drawn image? I am struggling to achieve this and would appreciate any help. I have been attempting to upload an image, draw it using the imageDraw() function, and fit it within a ...

Update the variable using Ajax after the content has loaded

I am struggling with the following code snippet: <?php $num=12; ?> <html> <head></head> <body> <div id="test"></div> <script type="text/javascript"> function fetchContent() { var ...

What factors influence Redux in determining when to update the user interface?

As per the design, when the state updates, the UI should also update accordingly. However, if I return a completely new object, it seems to have no effect on the UI. case 'clearArticleForm': let newState1 = {}; return newState1; } E ...

Encountering a connectivity issue with the MongoDB server

While I wrote my server IP on the mongoose connection string, I am unable to insert data into MongoDB. How can I resolve this issue? var express = require("express"); var app = express(); var mongoose = require('mongoose'); mongoose.connect(&ap ...

A quicker method for setting the emitted value to data

Is there a way to pass data from child to parent without creating a method for assigning the value? I want to be able to assign it directly in the template. This is my current code: Child <h1 @click="$emit('title', 'Home')&quo ...

The Material UI appbar fails to resize properly on mobile devices

I have added a material-ui appbar to the top of my website. Check it out here: Website Appbar However, when I resize the website to mobile size, the appbar does not adjust responsively to the screen. Here's how it looks on mobile: Appbar when in mobi ...

Understanding the Parameters for discord.js Slash Commands

I am currently working on a calculation that involves using parameters input through a slash command. While entering the parameters works without any issues, I am facing difficulty in retrieving them. The current code is resulting in an error TypeError: ...

Methods like jQuery blink(), strike(), and bold() offer dynamic ways to manipulate

I'm currently tackling an inquiry. The code I crafted seems to be functioning without any issues: (function () { if($('#target:contains("bold")')) { $('#target span:first').css('font-weight','bold ...

Differences between Mongoose's updateOne and save functions

When it comes to updating document records in a MongoDB database, there are several approaches to consider. One method involves defining the User model and then locating the specific user before making modifications and saving using the save() method: let ...

Backbone sorting is specifically designed for organizing views within the framework

As I work on creating a sorting function in backbone, I have come across recommendations to use views to listen for changes in collections and then render the views once the collections are sorted. However, this approach does not suit my needs for two main ...

What is the method for retrieving a module from a store using its name represented as a string?

Just starting out with Vuejs and encountering a slight hiccup. I want to utilize a store, however, all I have is the name stored as a string. From what I understand, I can access the method (all()) of the store by using: storeName.all My issue lies in ha ...

I am encountering a challenge when trying to invoke a different function within the Facebook login callback in my

In my Vue2 application, I have implemented a login system using Facebook login. This system captures the access token from the Facebook API and sends it to the backend for processing user data. When the user clicks on the "login with Facebook" button, the ...