Element-ui is used in the project. For example, I want to dynamically generate N components.
<template>
<p class="search" ref="search" v-html="sHtml">
</p>
</template>
<script type="text/javascript">
export default {
data() {
return {
sHtml: '',
}
},
props: {
con: {
type: Array
}
},
created() {
this.con.map((v, i) => {
this.sHtml += '<el-'+ v.type +' class="'+ v.style +'" placeholder="'+ v.placeholder +'" v-model="'+ v.name +'"></el-' + v.type +'>';
});
},
}
</script>
Is there any way to make the element plug-in render on the page?
黄舟2017-06-26 10:56:13
Can’t you be more direct, like
<p class="search" ref="search">
<el-input v-model="keyFrom.id" size="small" placeholder="请输入内容"></el-input>
</p>
PHP中文网2017-06-26 10:56:13
You can refer to: https://cn.vuejs.org/v2/guide...Dynamic components
<component v-for="item in con" :is="item.name"></component>