如何在数据 vue.js 2 中创建两个数组?

How can I make two array in data vue.js 2?

我这样试:

<template>
    ...
</template>
<script>
    export default {
        ...
        data() {
            return {
                tabs: [
                    {
                        sale:{
                            {
                                url: 'store/sale',
                                group: 'index'
                            },
                            {
                                url: 'store/confirm',
                                group: 'confirm'
                            },
                        },
                        purchase:{
                            {
                                url: '/profile/purchase',
                                group: 'payment'
                            },
                            {
                                url: '/profile/purchase/order',
                                group: 'order'
                            },
                        }
                    }
                ]
            }
        },
        ...
    }
</script>

如果执行代码,存在错误:

Uncaught Error: Module build failed: SyntaxError: Unexpected token

数据好像有错误

如何解决错误?

这是一个语法错误:

sale:{
      {
        url: 'store/sale',
        group: 'index'
      },
      {
        url: 'store/confirm',
        group: 'confirm'
      },
     }

purchase:{{})

我怀疑您希望它们是数组(用 [ ] 制作)而不是对象(用 { })。也许这就是您想要做的:

sale:[
      {
        url: 'store/sale',
        group: 'index'
      },
      {
        url: 'store/confirm',
        group: 'confirm'
      },
     ],
purchases[{
  // etc.
     }
    ]