老师,请问一下,用reactive定义数据,传给子组件,子组件为什么拿不到
来源:6-4 业务组件:移动端navigationBar

纯奶糖
2022-07-01
父组件
let categorys = reactive([])
// 获取主页列表数据
getCategory().then((res) => {
categorys = res.categorys || []
console.log(categorys)
})
子组件
import { defineProps, defineEmits } from 'vue’
defineProps({
data: {
type: Array,
required: true
}
})
console.log(data) // 报错 data未定义
写回答
1回答
-
Sunday
2022-07-01
你好
你应该这样
const props = defineProps({
data: {
type: Array,
required: true
}
})console.log(props.data)
00
相似问题