简体   繁体   English

如何在脚本标签vue js中渲染html

[英]How to render html in script tag vue js

I'm trying to render dynamic html in script tag我正在尝试在脚本标签中呈现动态 html

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 !但我不能将 function 分配给按钮或更多!

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

please help me.请帮我。

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.这将让 Vue 实际编译模板,在此期间它会遍历传递的属性。

Note: Vue.compile() returns a render function.注意:Vue.compile() 返回一个渲染 function。 https://v2.vuejs.org/v2/api/#Vue-compile https://v2.vuejs.org/v2/api/#Vue-compile

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM