知識點(diǎn)
school組件本質(zhì)上是一個(gè)VueComponent的構(gòu)造函數(shù),且不是程序員定義的,是Vue.extend生成的。
我們只要寫<school></school>或者<school/>,vue解析時(shí)會(huì)幫我們創(chuàng)建school組件的實(shí)例對象。即vue會(huì)幫我們執(zhí)行 new VueComponent(options)。
每次調(diào)用Vue.extend,返回的都是一個(gè)全新的VueComponent。
關(guān)于this的指向
①:組件配置中
data函數(shù),methods中的函數(shù),watch中的函數(shù),computed中的函數(shù),它們的this均是【VueComponent實(shí)例對象】。
②:new Vue(options)中:
data函數(shù),methods中的函數(shù),watch中的函數(shù),computed中的函數(shù),它們的this均是【Vue實(shí)例對象】