props
<script setup>
import { defineProps } from 'vue'
// expects props options
const props = defineProps({
foo: String,
})
</script>
emit
<script setup>
import { defineEmit } from 'vue'
// expects emits options
const emit = defineEmits(['update', 'delete'])
</script>
slots 和 attrs
<script setup>
import { useContext } from 'vue'
const { slots, attrs } = useContext()
</script>
$ref
- 使用@vitejs/plugin-vue:^1.9.3版本
- 2.0.0 会报错 $ref is not defined
// vite.config.js
export default defineConfig({
plugins: [
vue({ refTransform: true })
]
})
//index.vue
let count = $ref(0)