entry-runtime-with- compiler.js within
const mount = Vue.prototype.$mount
Vue.prototype.$mount = function (
el?: string | Element,
hydrating?: boolean
): Component {
el = el && query(el)
/* istanbul ignore if */
if (el === document.body || el === document.documentElement) {
process.env.NODE_ENV !== 'production' && warn(
`Do not mount Vue to <html> or <body> - mount to normal elements instead.`
)
return this
}
//太长了贴一部分
/runtime/ index.js
Vue.prototype.$mount = function (
el?: string | Element,
hydrating?: boolean
): Component {
el = el && inBrowser ? query(el) : undefined
return mountComponent(this, el, hydrating)
}
Then I created a few JS to try, why not test.js
function va(){}
export {va}
test1.js
import {va} from './test.js'
va.prototype.hei = function(){
alert(1)
console.log(1)
}
test2.js
import {va} from './test.js'
const ob = va.prototype.hei
va.prototype.hei = function(){
alert(2)
console.log(2)
}
test3.js
import {va} from './test.js'
var a = new va();
a.hei()
In the end, I only Alert2 and printed 2PS: I built several in order to keep similar, but why not
Const mount in source code= Vue.prototype. The end of $mount was called again, so it was executed twice
The last time you revised it va.prototype.hei What you call is what you call. It has something to do with the order you introduce.
var fn1 = function(){console.log('fn1')}
var fn2 = fn1
fn1 = function(){
console.log('fn1 update');
fn2.call(this);
}
fn1()
// --> fn1 update
// --> fn1