怎么将拼接的字符串element组件通过“v-html“渲染到页面

如上图所示,没那么多废话,直接上代码

html中
javascript 复制代码
<div id="app">
  	<div :html="tempHtml"></div>
</div>
vue中
javascript 复制代码
new Vue({
     el: '#app',
     data() {
         return {
             tempHtml: ''
         }
     },
     created() {
         this.getHtml()
     },
     mounted() {
         window.clickFun = this.clickFun;
     },
     methods: {
         getHtml() {
             let template = "<el-button type='primary' size='mini' @click='clickFun()'>查询</el-button>"
             this.tempHtml = template;
         },
         clickFun() {
             console.log(121212);
         }
     },
     render(h) {
         const com = Vue.extend({
             template: eval('`' + this.tempHtml + '`')
         });
         return h(com, {});
     }
 })
相关推荐
胖者是谁3 分钟前
EasyPlayerPro的使用方法
前端·javascript·css
EndingCoder10 分钟前
索引类型和 keyof 操作符
linux·运维·前端·javascript·ubuntu·typescript
摘星编程1 小时前
React Native for OpenHarmony 实战:ImageBackground 背景图片详解
javascript·react native·react.js
摘星编程2 小时前
React Native for OpenHarmony 实战:Alert 警告提示详解
javascript·react native·react.js
Joe5562 小时前
vue2 + antDesign 下拉框限制只能选择2个
服务器·前端·javascript
WHS-_-20222 小时前
Tx and Rx IQ Imbalance Compensation for JCAS in 5G NR
javascript·算法·5g
摘星编程2 小时前
React Native for OpenHarmony 实战:GestureResponderSystem 手势系统详解
javascript·react native·react.js
lili-felicity2 小时前
React Native for OpenHarmony 实战:加载效果的实现详解
javascript·react native·react.js·harmonyos
济6173 小时前
linux 系统移植(第六期)--Uboot移植(5)--bootcmd 和 bootargs 环境变量-- Ubuntu20.04
java·前端·javascript
lili-felicity3 小时前
React Native for OpenHarmony 实战:Easing 动画完全指南
javascript·react native·react.js