vue不能在根节点中使用v-for
来源:互联网 发布:网络喷子被打 编辑:程序博客网 时间:2024/06/05 05:25
碰到一个像这样的问题
<template>
<ul class="mainmenu" @touchstart="touchMainMenu" ref="mainmenu" v-for="item,index in menuItems" :key="index"><li>{{item.title}}</li>
</ul>
</template>
直接编译报错:
Cannot use v-for on stateful component root element because it renders multiple elements
查过很多文章,大致意思就是 v-for不能用于根元素(root element)。因为v-for是个循环,它返回更多的元素。导致无法渲染。
因为vue这个时候不知道该怎么渲染,因为div是根元素,vue不知道该如何将key,value渲染到那个html标签中
阅读全文
0 0
- vue不能在根节点中使用v-for
- vue不能在根节点中使用v-for
- vue不能在根节点中使用v-for
- vue.js 中的在v-for节点中嵌入 v-if 的解释
- vue中使用v-for,出现告警!
- vue 中,v-for和v-if同时使用
- vue的v-for使用
- vue中v-for的使用,离不开的数组
- Vue 中使用v-for语句抛出错误的解决方案
- vue.js中v-for的使用及索引获取
- vue中如何在v-for中动态的使用将index拼接字符串后绑定id属性
- Vue中v-for的数据分组
- VUE中v-if和v-for介绍
- vue中v-if与v-for的区别
- vue v-for v-if
- vue v-for 数据处理
- vue v-for详解
- vue v-for 嵌套
- Cocos2dx 3.0开发环境搭建--Eclipse上构建一个Android项目
- 关于进程状态的表示
- 如何向妻子解释设计模式
- unity着色器基础(二)
- 动态生成sql语句实例
- vue不能在根节点中使用v-for
- vue不能在根节点中使用v-for
- leetcode 1. Two Sum [Easy]
- snmp源代码结构
- Mac homebrew 安装 python2
- spring <context:component-scan>使用说明(转)
- Linux系统编程复习
- 深度学习日记 2
- Swift 4官方文档中文版/ Basic Operators(下)