Why is it that some of the vue source code is added through the Vue.prototype.fun method, and some are directly added by Vue.fun?

clipboard.png

clipboard.png
I am confused when I read the vue source code for the first time today.

Mar.04,2021

thanks for medicine

function  Obj(){

}
Obj.a=1
Obj.d=4
Obj.prototype.a=2
var c=new Obj()
console.log(c.a)//2
console.log(c.d)//undefined

subcomponents (classes) can inherit methods of parent components (classes) through prototype, while directly defined methods cannot be used in subcomponents


you can think of Vue as a class (that is, class Vue {} in ES6 or function Vue () {} in ES5).

In the

figure, Vue.use is the class method of Vue , that is, the method called directly through Vue.use () . This method is used to extend the plug-ins of Vue . If you want to use some plug-ins in the project, such as Element UI , you need to introduce them through this method.

and the method defined by Vue.pototype.fun is a method used within a Vue component, that is, if you want to use the method fun , you need to call it within the component defined with Vue , not directly using Vue.fun .


the difference between static methods and instance methods. Vue.prototype.fun is the add instance method, and Vue.fun is the add static method.


is the difference between class methods and instance methods

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3bdf2-2b815.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3bdf2-2b815.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?