(六)这一节单讲,vue3的升级的变化

这一节单讲,vue3的升级的变化

useURLLoader 这一节说的就是你使用axios的时候 返回的一个响应式的返回结果 声明的就是一个响应式对象 返回对应的连接

使用ts进行泛型改造 类型约束 就是你获取上面的那个类型的时候没有相应的值 所以使用泛型进行约束

vue2 在使用 typescript的时候 ,因为没有集成,所以很多都是在使用 vueclass 或者 extends 的使用方法
vue3 怎么解决:
import {defineComponent} from 'vue'

 要是你不写这个 defineComponent 提示啥的都没有,就相当于你是使用这个进行了一次创建
 export default defineComponent({
	name:'Hello Word',
	props:{
		msg:{
			required:true,
			type:String	
		}
	},
	最最重要的 setup 接收两个参数 props是组件接收的数值,context类似于上下文的this 携带(attrs slots emit)
	setup( props , context){
		props.msg
		
		这三个在使用的时候都是最新的值的
		context.attrs  ———— $attribute 属性
		constext.slots ————插槽
		context.emit ———— 事件对象
	}

 })

vue2的 lagacyOptions 是vue2 中的一些事件对应的方法(data computed ... 等等)

vue3 其实就是在setup中: ComponentOptionsBase vue3所对应的一些方法

posted @ 2022-05-30 10:33  无梦南柯  阅读(63)  评论(0编辑  收藏  举报