项目运行提示信息

翻译提示:
警告信息本身意思是:在 <script setup> 中 直接使用defineProps,不需要再import。
vue3 setup语法糖:
在 <script setup> 中必须使用 defineProps 和 defineEmits API 来声明 props 和 emits ,它们具备完整的类型推断并且在 <script setup> 中是直接可用的.
修改
1、import 中去掉 defineProps
2、直接定义:
const props=defineProps({
dialogTitle: {
type: String,
default: '',
required: true
},
})
3、watch监控
watch(
() => props.dialogValue,
(newV)=>{
console.log(newV)
},
{ deep: true, immediate: true }
)
本文介绍了在Vue3的<scriptsetup>中,如何移除defineProps的导入,直接使用prop声明,并利用新的类型推断功能。同时展示了如何在setup中使用watch进行深度监听。

374

被折叠的 条评论
为什么被折叠?



