在script setup 中使用props和emit要使用defineProps,defineEmits。
直接使用会报未定义,需要配置eslint。
1.直接关掉eslint(不建议这种)
2. 根据官网配置
链接:https://eslint.vuejs.org/user-guide/#faq
'vue/setup-compiler-macros': true
子组件
<template>
<div>
{{ str }}
<P @click="del">点我</P>
</div>
</template>
<script setup>
const props = defineProps({
str: String
})
const emit = defineEmits(['myevent'])
let del=()=>{
console.log('ssssssssss')
emit('myevent',false)
}
console.log(props.str)
</script>
<style scoped>
</style>
<RightCompont str="踩踩我是谁" @myevent="del" ></RightCompont>