组合式函数 中如何获取到 props #10740
Unanswered
itwmike
asked this question in
Help/Questions
组合式函数 中如何获取到 props
#10740
Replies: 3 comments
-
使用defineProps 提示 defineProps() is a compiler-hint helper that is only usable inside <script setup> of a single file component. Its arguments should be compiled away and passing it at runtime has no effect. |
Beta Was this translation helpful? Give feedback.
0 replies
-
export default {
props: ['foo'],
setup(props) {
// setup() 接收 props 作为第一个参数
console.log(props.foo)
}
} 或者你可以干脆直接使用单文件组件+ |
Beta Was this translation helpful? Give feedback.
0 replies
-
defineProps 是编译器行为,不可以那样用。你可以把props传入composable |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
组合式函数 中如何获取到 props
Beta Was this translation helpful? Give feedback.
All reactions