鉴于以下Vue3证监会守则:
<template>
<div>{{msg}}</div>
</template>
<script setup>
const props = defineProps({
msg: {
type: String,
default: 'Hello world'
}
})
</script>为什么道具值props.msg可以直接从模板标记中引用,而不需要我编写<div>{{props.msg}}</div>,这叫什么?
如有任何关于这方面的文件,将不胜感激。
发布于 2022-10-21 13:24:53
传递给defineProps的选项(在您的例子中是msg)将从安装程序中提升到模块作用域中。您不能引用在安装范围中声明的局部变量(在您的例子中是props)。更多这里
https://stackoverflow.com/questions/74153644
复制相似问题