RE: RE: Nuxt开发指南
You are viewing a single comment's thread from:

RE: Nuxt开发指南

Words
10
Reading
1 min
Listen
Play
7M

defineProps来接受父组件传来的值

//index.vue
<Menu :active = "active"></Menu>
<NuxtPage :collection="defaultCollection" />

//Menu.vue 接受参数
defineProps({
  active:{
      type:Boolean,
      default:false
  },
  ckey:{
    type: Number
  }
})
//在 div 中可直接使用,例如: {{ active }} {{ ckey }}


const props = defineProps({
        title: String,
        info: String,
        author: String,
    })

// 等价于以 字符串数组声明 props
//const props = defineProps(['title', 'info', 'author']);
// 如果在setup中使用则直接 props.title