javascript - Is there any way to make the components spliced ​​together by vue effective?
阿神
阿神 2017-06-26 10:54:13
0
5
778

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?

阿神
阿神

闭关修行中......

reply all(5)
仅有的幸福

Can’t v-for directly where the component is referenced? .

黄舟

Can’t you be more direct, like

    
 
 <p class="search" ref="search">
     <el-input  v-model="keyFrom.id" size="small" placeholder="请输入内容"></el-input>
 </p>
世界只因有你

Compiling html is not supported now, but it will be possible in 1.0

習慣沉默

Use v-for directly to render components through data [array]

洪涛

You can refer to: https://cn.vuejs.org/v2/guide...Dynamic components

<component v-for="item in con" :is="item.name"></component>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template