vue3.3新特性
# vue3.3新特性
# defineOptions
主要是用来定义Option选项,如
<script setup>
defineOptions({
name: 'app' // 名字之类的
})
</script>
1
2
3
4
5
2
3
4
5
# defineModel
1.首先需要引入
<script>
import { defineOptions } from 'vue
</script>
1
2
3
2
3
2.vite.config.js进行配置
export default defineConfig({
plugins: [
vue({
script: {
defineModel: true
}
})
]
})
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
# 新增泛型的支持
对defineprops的改进,新增泛型支持需要在script标签加上generic="T"
const defineProps = defineProps<{
name: T[]
}>
1
2
3
2
3
对于事件
const emit = defineEmits<{
'send': [name: string]
}>
1
2
3
2
3
上次更新: 2023/08/29, 7:08:00