0

есть такой template:

<template>  
    <header class='header'>
        {{ msgHead }}
    </header>
    <input class='input-add' type='text' v-model='textTodo' @keypress.enter='addTodo' />
    <ul class='todos' v-if='todos.length'>
        <Todo
            v-for='todo in todos'
            :key='todo.name'
            :todo='todo'
            @remove='removeTodo'
        />
    </ul>
</template>

Какие есть способы это отрендерить? Оборачивать в дополнительный тег ?

1 ответ 1

0

Да, необходимо обернуть всё, что внутри template в div.

Vue необходимо, чтобы корневой элемент был только один, поэтому:

<template>
    <div>
        <header class='header'>
            {{ msgHead }}
        </header>
        <input 
            class='input-add' 
            type='text' v-model='textTodo' 
            @keypress.enter='addTodo' 
        />
        <ul class='todos' v-if='todos.length !== 0'>
            <Todo
                v-for='todo in todos'
                :key='todo.name'
                :todo='todo'
                @remove='removeTodo'
            />
        </ul>
    </div>
</template>

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.