vue3新语法糖script setup基本用法

1、组件引入

直接使用import引入,无需注册

2、组件传值

1、父组件传子组件使用props(需要先引入defineProps)

父组件绑定
image
子组件声明
image

2、子组件触发父组件使用emilt(需先引入defineEmit)

子组件
image
父组件在引入的子组件上使用@符加上emit(name)

3、 Provide/inject(不限层级)

父组件中
image
子组件或子孙组件中
image

4、 vuex提升为全局变量使用

image

posted @ 2021-11-05 14:23  举个栗子走天下  阅读(1235)  评论(0)    收藏  举报