I have a question. I have a component called ValidateCheckboxes. ValidateCheckboxes is a validated list of checkboxes. I pass checkboxes to this component by props. It look like that:
enter image description here
enter image description here
I am displaying checkboxes using v-for:
enter image description here
but my label look like this:
enter image description here
How to render custom component from string? Or maybe should I use another way to do that?
It's my first question, thanks for answers. :)
I tried use v-html but it didn't work.
You should use slots, as they provide more control.
If you absolutely can't do that because stuff is loaded from a file, database or otherwise fetched from API - you can look into h() and compile() - How I can render a component from a string with vue 3?
Related
I want to make data grid component in vue3
But the problem is, for different type of data, I need to add different type of action buttons.
Please see the image bellow, I have described in the photo, what I want.
Please advice me.
Codes zip link given below:
Click here to get code
I'm using vue-select.
When I want to display the selected element, it shows me the value and not the text (see the screen).
I saw on several reports (and on the documentation) that I could use reduce.
I also saw that I could add a ":key" props on the component but that doesn't work either.
Here I choose the item :
Here the selected item, it displays the value and not the text : (Here the problem)
My component file (input-custom.vue) :
My component in page:
Data in page:
I found the solution.
This is my "handleInput" method.
I emit "e.value" but I want to emit the Object, so replace "e.value" => "e"
I am using vue2-editor and i want to toggle the content view of the editor like ckeditor or mailchimp editor does
It is possible using vue2-editor or quill?
You can have a computed property that either returns the actual text or uses a library like hypertext to generate html, the return value of the html would be contingent on another computed property and returns the html you want.
I also have a simpler solution, which I used once but need to take a look at my code in a few hours which is not in front of me.
I am currently developing a web application that is used to display elements for events on a map provided by HERE Maps. I am using Vue.
I have some components, but the relevant component is the component HereMaps.vue which initializes the map using the HERE Maps Api.
The HERE Maps Api provides the possibility to place so called InfoBubbles on the map showing additional information. These InfoBubbles can be provided some HTML-code in order to customize their appearance.
Please refer to the documentation for additional information
Following the documentation the code looks something like this:
let bubble = new H.ui.InfoBubble(marker.getPosition(), {
content: "<div class='someClass'>Some Content</div>"
});
this.ui.addBubble(bubble)
This is happening after mount in the "mounted" method from Vue in the "HereMaps" component.
The Bubbles are added in a "closed" (hidden) form and dynamically "opened" to reveal their content when the corresponding marker icon on the map is clicked. Therefore the HTML-code is present on the DOM after the component is mounted and is not removed at a later stage.
Now instead of supplying custom code within each bubble added to the UI i want to just add a component like this:
let bubble = new H.ui.InfoBubble(marker.getPosition(), {
content: "<myDynamicComponent></myDynamicComponent>"
});
this.ui.addBubble(bubble)
It does not matter to me wether the component is initialized using props or if it is conditionally rendered depending on the state of a global variable. I just want to be able to use the "myDynamicComponent" in order to customize the appearance in a different file. Otherwise the design process gets very messy.
As far as i know this is not possible or at least i was not able to get it work. This is probably due to the fact that the "myDynamicComponent" is not used within the "template" of the "HereMaps" component und thus Vue does not know that it needs to render something here after the directive is added to the DOM in the "mounted" method.
This is what the InfoBubble looks using normal HTML as an argument:
This is what the InfoBubble looks using the component as an argument:
It appears to just be empty. No content of the "myDynamicComponent" is shown.
Does anyone have any idea how i could solve this problem.
Thank You.
Answer is a bit complicated and I bet you wouldn't like it:)
content param can accept String or Node value. So you can make new Vue with rendered your component and pass root element as content param.
BTW, Vue does not work as you think, <myDynamicComponent></myDynamicComponent> bindings, etc exists in HTML only in compile time. After that all custom elements(components) are compiled to render functions. So you can't use your components in that way.
Give us fiddle with your problem, so we can provide working example:)
I created a component and used it with vue-router. However, when I update the webpage it told me that "the data 'sss' is not defined."enter image description here
and this is my component:
enter image description here
I am sure that I have already define the data. so what's wrong?
It looks like you just have a type, it's data not deta
Also for future reference please copy and paste your code, don't post screen shots otherwise we will have to type everything out if your question requires an answer with the code.