Incorporate PrimeVue into Vue's custom elements

Can you guide me on integrating a PrimeVue component into a Vue3 custom element?

I have created a Vue3 composition+setup custom element. I expect the button to be styled with PrimeVue and appear red due to the severity="danger" attribute.

However, it appears as a plain unstyled button.

<script setup lang="ts">
</script>

<template>
    <Button severity="danger">Hello</Button>
</template>

<style scoped lang="scss">
</style>

This is how I included the custom element in my main file:

import MyElement from "@/views/MyElement.ce.vue";
customElements.define('my-element', defineCustomElement(MyElement))

Here is the plugins section in my Vite config:

plugins: [vue({
        template: {
            compilerOptions: {
                isCustomElement: (tag) => tag.startsWith('my-')
            }
        }
    })],

You can check out the code in this CodeSandbox link.

Answer №1

Thanks to a generous member of the Vue community, I was able to resolve this issue.

You can find the functional code in the codesandbox.

Here is the modified custom element that made it work seamlessly.

It was also necessary to have primevue version 3.38 or higher for it to function properly.

<script setup lang="ts">
import Button from "primevue/button";
</script>

<template>
  <Button severity="danger">Hello</Button>
</template>

<style scoped>
@import "primevue/resources/themes/lara-dark-teal/theme.css";
@import "primevue/resources/primevue.min.css";
</style>

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

Creating a video that plays frame-by-frame on an HTML5 canvas and can be controlled with a slider

I am currently working on a walkthrough video where the user has the ability to slide a UI slider across the screen, causing the camera to navigate through a 3D space. The video itself has been exported in jpg frames, numbered from 0 to 350.jpg. My appro ...

Access the outcome by utilizing a for loop

Within my code, I am utilizing both a function and a loop: var songs = Musics.searchSongs(query).then(function(rs) { return rs; }); for (var i = 0; i < songs.length; i++) { console.log(songs[i]); } I am now looking for a way to execute the ...

Getting Started with NodeJS Child Process for Electrons

My current challenge involves integrating a Gulp setup with debugging electron-quick-start. I am attempting to close and reopen Electron when changes are made to my source files using child_process.spawn. Launching the application seems to work fine, but w ...

How can I stop a hyperlink from activating Jquery?

A script was created to highlight any <TR> element when a user clicks on it, and it is functioning correctly. <script> $(document).ready(function () { $(document).on('click', 'tbody tr', function (e) { ...

Managing memory usage in Nuxt and preventing leaks

Currently running on Nuxt v2.13 and Vuetify v2, along with using keep-alive in the default layout. I've encountered a memory issue as my application grew in size, requiring at least 4GB of RAM on a cloud server to function properly. After researching ...

Creating dynamic web pages with jQuery is a simple and effective

I am currently using jQuery to create HTML elements with specific classes and then append them together. However, the code I have written is not adding the generated HTML to the container as expected. There are no errors being produced but the HTML is not ...

Symfony along with React router have encountered an error: route not found

In my current project, I am working with Symfony3 and integrating React.js along with react-router to create a bundle. One issue I have encountered is that when using the routing in React, if I refresh the page, the Symfony routing module displays 'N ...

Meteor application: The correct method for fetching a single document from a collection on the client side

Currently in my meteor app, I am saving the unique id of the client within a collection named UserNavigationTracker: { "clientId" : "xxNfxxPGi7tqTbxc4", "currentWizard" : "IntroductionWizard", "currentStep" : "Step-1", "_id" : "ifBJ688upEM ...

Error in Displaying Vuetify Child Router View

I am currently working on integrating a child router-view to be displayed alongside surrounding components. Here is an overview of my routing setup: { path: "/login", name: "TheLoginView", component: TheLoginView, }, { path: "/dashboa ...

Encountering a 404 error in a Next.js application while utilizing path parameters

Embarking on my journey into web development, I am trying to grasp the concept of server-side rendering using next.js and react within a lambda function. When running the code on a lambda, the result is somewhat functional as it displays the parameter valu ...

What is the best way to create a connected secondary list in Vue.js using JSON data directly?

I am facing an issue with my state and district list stored in a .json file. While I am able to display the list of states in the first dropdown menu, I am struggling to display the corresponding district list for the selected state in the second dropdown. ...

The function Jquery .stop does not exist

I am encountering an issue with the magicline.stop function while attempting to implement an underline sliding effect for my navbar. I have tried to troubleshoot the problem but have been unsuccessful so far. Below is the code snippet: <nav class=" ...

Creating a private variable in Javascript is possible by using getter and setter functions to manage access to the

Is this the correct way to simulate a private variable? var C = function(a) { var _private = a + 1; // more code... Object.defineProperties(this, { 'privateProp': { get: function() { return _privat ...

Display a loader in Vue JS at the start and then remove it once the response is received

To achieve the functionality of showing a loader initially and hiding it after receiving a response, you can use the following code: <template> <div id="app"> <Document :loading="loading"> </div> </tem ...

Retrieving a Date object from a JSON response

Hey there, I have a situation where I'm trying to convert a JSON response into a date object in order to display it in a different format. Here's the JSON response I'm working with: responseData: [{"id":10,"createdDate":"1 Sep, 2014 12:48:5 ...

When using jquery.hide() and show(), the content within the div disappears momentarily before reappearing

Hello! I am experiencing an issue where the content of my div disappears after using a jQuery hide() and show() function. It seems to be gone. <li class="gg3"><a class="link" href="#" data-rel="content3">Link1</a></li> <div clas ...

Verify if a certain value is present within a nested array

I need assistance with checking if a specific value is present within a nested array. Here is an example of the data I am dealing with: [ { name: 'alice', occupation: ['Artist', 'Musician'], }, { ...

I'm having trouble with populating data in Mongoose. Can anyone provide guidance on

I am currently working on a simple CRUD example for a larger open-source project. I'm trying to populate user data, but despite consulting documentation and forums, I haven't been able to resolve the issue that's causing trouble. The error ...

Angular ng-repeat not recognizing nested ng-if conditions

Hey there, I'm trying to make sure that only the option corresponding to the code used by the client to log in is displayed. The HTML should show the option that matches the client's login code. View: <div class=""> <select id="custo ...

Tips on emphasizing all div elements and incorporating navigation to each of them

I am seeking a method to enhance a div with highlighting when there is a click or mouseover event. For instance, changing or adding a border color using JavaScript on click or mouseover is straightforward. Recently, I have been contemplating the idea of a ...