首页 > 解决方案 > Vuejs dynamic directives v-for loop

问题描述

I have the following code, but displays text and don't instantiate the steps.

How can i achieve that?

Template:

<template>
    <div>
        <ul>
            <li v-for="(step, index) in $store.state.steps" >
                <{{`step-${index+1}`}}></{{`step-${index+1}`}}>
            </li>
        </ul>
    </div>
</template>

Output:

<step-1></step-1>
<step-2></step-2>
<step-3></step-3>
<step-4></step-4>
<step-5></step-5>
<step-6></step-6>
<step-7></step-7> 

标签: vuejs2vue-directives

解决方案


Read documentation here https://vuejs.org/v2/guide/components-dynamic-async.html

<component v-bind:is="currentComponent"></component>

推荐阅读