1

I'm trying to render dynamic html in script tag

I'm create a custom data-table component for my project and now i trying to use a column for operations

but I can't assign function to button or more !

{
     field: 'operation',
     title: 'Operations',
     template: (e) => {
         return '<button v-on:click="methodFunction">Click</button>';
     }
}

please help me.

1 Answer 1

2

Which library are you using for creating the Data Table component?

You might try something like:

{
     field: 'operation',
     title: 'Operations',
     template: Vue.compile('<button v-on:click="methodFunction">Click</button>')
}

This will let Vue actually compile the template, during which it goes through the attributes passed.

Note: Vue.compile() returns a render function. https://v2.vuejs.org/v2/api/#Vue-compile

Sign up to request clarification or add additional context in comments.

2 Comments

thanks , but its not working too . when i use this , give Vue is not defined error
Hey I thought it was implicit. Add to the top of the file: import Vue from 'vue';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.