定义数据:
html结构:
{
{ message }}
{
{ list }}
{
{ web }}
输出结果:

v-for对数组的几种输出方式:
1.只输出value值
html代码:
{
{ item }}

2.输出value值且输出对应的索引值
html代码:
{
{ item }}的索引值是{
{ index }}
输出结果:

v-for对json格式的几种输出方式
1.只输出value值
html代码:
{
{ item }}
2.输出value值和key值
html代码:
{
{ key }} 的网址是 : {
{ item }}

3.输出value值,key值和索引值index
html代码:
{
{ index }}__{
{ key }} 的网址是 : {
{ item }}

可以看出,在数组里面,小括号里面的参数第一位是value值,第二位是索引值
在json里面,第一位是value值,第二位是key值,第三位是索引值
有的文章里面说$index是数组的内置变量数组下标,$key是json内置变量,可是我没有测出来,且提示有错,不知道这个到底对不对。
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/177333.html原文链接:https://javaforall.net
