javascript - When vue uses curly braces to wrap props, why is it translated into a JSON string?
phpcn_u1582
phpcn_u1582 2017-05-19 10:21:11
0
1
480
<template>
<sider :labels={labels}></sider>
</template>

<script>
import Sider from '@/components/Sider'
export default {
  name: 'Main',
  components: {
    Sider,
  },
  data() {
    return {
      labels: [1, 2, 3, 4],
    }
  }
}
</script>

As shown in the sample code, the value of labels prop received by sider is '[1, 2, 3, 4]', which is the JSON string form of data.labels?

Excuse me, why is this translation allowed? In what scenarios is it mainly used?

phpcn_u1582
phpcn_u1582

reply all(1)
仅有的幸福

This is es6 writing method
equivalent to
<sider :labels="{labels:labels}"></sider>

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!