vue.js鏄竴涓敤浜庢瀯寤虹敤鎴风晫闈㈢殑娓愯繘寮忔鏋躲€傚畠杞诲阀鏄撳锛屽彈鍒颁紬澶氬紑鍙戣€呯殑鍠滅埍銆備簡瑙f簮鐮佹湁鍔╀簬鎴戜滑娣卞叆鐞嗚Вvue銆傜煡閬撳畠鏄粈涔堜互鍙婁负浠€涔堜細杩欐牱鏄瘡涓伐绋嬪笀杩涙鐨勫敮涓€閫斿緞銆傝瘽涓嶅璇达紝杩涘叆姝i銆備竴銆佹ā鍧楁杩皏ue鐨勬簮鐮佷富瑕佸垎涓?澶фā鍧椼€傛ā鍧楀悕绉拌鏄嶤ompiler缂栬瘧鐩稿叧corevue鏍稿績浠g爜骞冲彴骞冲彴锛岀洰鍓嶆槸web鍜寃eexserver鏈嶅姟鍣ㄦ覆鏌搒fc.vue鏂囦欢瑙f瀽鍏变韩鍏变韩浠g爜2.涓诲叆鍙e垎鏋怴ue浣跨敤rollup鍋氭墦鍖呭伐鍏凤紝鍏堢湅package涓殑鑴氭湰.json銆俻ackage.json"scripts":{"dev":"rollup-w-cscripts/config.js--environmentTARGET:web-full-dev","dev:cjs":"rollup-w-cscripts/config.js--environmentTARGET:web-runtime-cjs-dev","dev:esm":"rollup-w-cscripts/config.js--environmentTARGET:web-runtime-esm","dev:test"锛氣€滀笟鍔涘紑濮嬫祴璇?鍗曞厓/karma.dev.config.js鈥濓紝鈥渄ev锛歴sr鈥濓細鈥渞ollup-w-cscripts/config.js--environmentTARGET锛歸eb-server-renderer鈥濓紝鈥渄ev锛歝ompiler":"rollup-w-cscripts/config.js--environmentTARGET:web-compiler","dev:weex":"rollup-w-cscripts/config.js--environmentTARGET:weex-framework","dev:weex:factory":"rollup-w-cscripts/config.js--environmentTARGET:weex-factory","dev:weex:compiler":"rollup-w-cscripts/config.js--鐜TARGET:weex-compiler","build":"nodescripts/build.js","build:ssr":"npmrunbuild--web-runtime-cjs,web-server-renderer","build:weex":"npmrunbuild--weex","test":"npmrunlint&&娴侀噺妫€鏌?&npmruntest:types&&npmruntest:cover&&npmruntest:e2e----envphantomjs&&npmruntest:ssr&&npmruntest:weex","test:unit":"karmastart娴嬭瘯/鍗曞厓/karma.unit.config.js","test:cover":"karmastarttest/unit/karma.cover.config.js","test:e2e":"npmrunbuild--web-full-prod,web-server-basic-renderer&&nodetest/e2e/runner.js","test:weex":"npmrunbuild:weex&&jasmineJASMINE_CONFIG_PATH=test/weex/jasmine.js","娴嬭瘯:ssr":"npmrunbuild:ssr&&jasmineJASMINE_CONFIG_PATH=test/ssr/jasmine.js","test:sauce":"npmrunsauce--0&&npmrunsauce--1&&npmrunsauce--2","test:types":"tsc-p./types/test/tsconfig.json","lint":"eslintsrcscriptstest","flow":"flowcheck","sauce":"karmastarttest/unit/karma.sauce.config.js","bench:ssr":"npmrunbuild:ssr&&nodebenchmarks/ssr/renderToString.js&&鑺傜偣鍩哄噯/ssr/renderToStream.js","release":"bashscripts/release.sh","release:weex":"bashscripts/release-weex.sh","release:note":"nodescripts/gen-release-note.js","commit":"git-cz"}锛屾垜浠富瑕佺湅鏋勫缓鍛戒护锛歯odescripts/build.jsscripts/build.js涓昏浠g爜濡備笅锛氳builds=require('./config').getAllBuilds();//杩欓噷鐪佺暐n琛宐uild(builds)鏍规嵁config.js鑾峰彇getAllBuilds鏂规硶锛岃繖閲岀湅杩愯鏃?缂栬瘧鍣ㄧ増鏈鏄庯紝缂栬瘧鍣╲ue鐨勫垎涓轰袱绉嶆儏鍐碉紙web绔級锛氫娇鐢╲ue-loader鏋勫缓缂栬瘧鍣紝绠€绉帮細vue杩愯鏃舵瀯寤虹紪璇戝櫒锛岀劧鍚庡啀鍘荤紪璇戝櫒锛岀畝绉帮細runtimecompiler銆傝繖閲岋紝鎴戜滑鑰冭檻瀹屾暣鐗堢殑vue婧愮爜锛岄€夋嫨runtime+runtimecompilerversion//Runtime+compilerESmodulesbuild(fordirectimportinbrowser)'web-full-esm-browser-prod':{entry:resolve('web/entry-runtime-with-compiler.js'),dest:resolve('dist/vue.esm.browser.min.js'),鏍煎紡:'es',transpile:false,env:'production',alias:{he:'./entity-decoder'},banner}鑷虫锛屾垜浠壘鍒颁簡vue鐨勪富瑕佸叆鍙f枃浠秪3.Vue鐨勭湡闈㈢洰鏄粈涔堬紵鎴戜滑杩涘叆entry-runtime-with-compiler.js涓绘枃浠讹紝鍏堝垎鏋愪富骞诧紝鍏堟妸鍒嗘敮鏀惧湪涓€杈癸細//...importVuefrom'./runtime/index'import{compileToFunctions}from'./compiler/index'//...Vue.prototype.$mount=function(){//...}Vue.compile=compileToFunctionsexportdefaultVueruntime/index鎴戜滑杩涘叆runtime/index.js锛岀户缁粠'core涓鎵緑ueimportVue/index'//...exportdefaultVuecore/indeximportVuefrom'./instance/index'import{initGlobalAPI}from'./global-api/index'//...initGlobalAPI(Vue)//...exportdefaultVueinstance/index鍒拌繖閲岋紝鎴戜滑缁堜簬鐪嬫竻浜哣ue鐨勭湡闈㈢洰锛屽畠鍏跺疄鏄竴涓瀯閫犲嚱鏁般€備粠'./init'瀵煎叆{initMixin}浠?./state'瀵煎叆{stateMixin}浠?./render'瀵煎叆{eventsMixin}浠?./events'瀵煎叆{lifecycleMixin}浠?./lifecycle'import{warn}from'../util/index'functionVue(options){if(process.env.NODE_ENV!=='production'&&!(thisinstanceofVue)){warn('Vue鏄竴涓瀯閫犲嚱鏁帮紝搴旇鐢╜new`鍏抽敭瀛楄皟鐢?)}this._init(options)}initMixin(Vue)stateMixin(Vue)eventsMixin(Vue)lifecycleMixin(Vue)renderMixin(Vue)exportdefaultVue杩欓噷鎴戜滑宸茬粡鐪嬪埌浜嗭紝vue涔嬪悗銆俲s鍔犺浇鍚庯紝鍒濆鍖栦簡5涓柟娉曪紝鍒嗗埆鏄痠nitMixin銆乻tateMixin銆乪ventsMixin銆乴ifecycleMixin銆乺enderMixin銆傛帴涓嬫潵锛屾垜浠竴涓€鍒嗚В銆?.initMixinVue.prototype._init=function(options?:Object){constvm:Component=this//...}Vue鍦ㄨ繖涓柟娉曚腑澹版槑浜哶init鏂规硶銆傝繖鍏跺疄灏辨槸鎴戜滑鍦ㄤ娇鐢╲ue鏃讹紝newVue(options)锛屽疄渚嬪寲vue鏃舵墽琛岀殑鏂规硶銆傝鏂规硶鏍稿績娴佺▼濡備笅锛?.鍚堝苟options閰嶇疆锛屾寕杞藉埌vm.$options2.InitLifecycle鍒濆鍖杤m.$parent,vm.$root,vm.$children,vm绛夊睘鎬?$refsValue3.initEvents鍒濆鍖杤m._events={}锛屽垵濮嬪寲浜嬩欢绯荤粺鍏跺疄灏辨槸妯℃澘涓埗缁勪欢浣跨敤v-on鎴栬€匑娉ㄥ唽瑙﹀彂鐨勪簨浠讹紝鐩戝惉瀛愮粍浠?.initRender涓昏瀹氫箟2涓柟娉曪細vm._c锛岃鏂规硶鐢ㄤ簬鐢ㄦ埛浣跨敤妯℃澘妯″紡vm.$createElement锛岃鏂规硶鐢ㄤ簬鐢ㄦ埛鎵嬪啓render鍑芥暟鐨勪袱涓柟娉曪紝鏈€缁堜細璋冪敤createElement鏂规硶銆俢reateElement鏂规硶灏嗗湪铏氭嫙DOM绔犺妭杩涜鍒嗘瀽銆傝繖閲屾垜浠彧闇€瑕佺煡閬擄紝杩欎釜鏂规硶杩斿洖鐨勬槸铏氭嫙DOM5銆傝皟鐢╞eforeCreatehook6.initInjections杩欎釜鏂规硶锛宨nject鍜宲rovide鎴愬鍑虹幇銆備綔鐢ㄦ槸鐖剁粍浠舵彁渚涙暟鎹紝浠讳綍宓屽绾у埆鐨勫瓙缁勪欢閮藉彲浠ユ帴鍙椼€傚叾涓璸rovide鏄暟鎹彁渚涜€咃紝inject鏄暟鎹帴鏀惰€呫€?.initState鍒濆鍖杝tate銆乸rops銆乵ethods銆乧omputed銆亀atch銆傚湪鍒濆鍖杝tate銆乸rops銆乵ethods鏃讹紝vue浼氶亶鍘哾ata涓殑鎵€鏈塳ey锛屾娴嬫槸鍚﹀湪props鍜宮ethods涓€俻rops鍙橀噺鐨勯噸澶嶅啓娉曟湁寰堝绉嶏紝vue浼氱粺涓€鏀归€狅紝鍙樻垚{a:{type:"xx",default:'xx'}}骞跺皢data鍜宲rops鎸傝浇鍒皏m._data鍜寁m._props涓娿€傝缃闂暟鎹唬鐞嗭紝璁块棶this.xx锛屽疄闄呰闂畍m._data[xx],vm._props[xx]涓篲data,_props娣诲姞鍝嶅簲寮忕洃鍚?.initProvide鍚宨nitInjections9銆傝皟鐢╟reatedhook5.stateMixin瀹氫箟Vue.prototype.$data锛孷ue.prototype.$props鏄搷搴斿紡鐨勩€傝幏鍙杤m.$data鍏跺疄灏辨槸鑾峰彇vm._data锛岃€寁m.$props鍏跺疄灏辨槸vm._props瀹氫箟浜哣ue.prototype.$watch鏂规硶锛屽叾瀹炲氨鏄疄渚嬪寲浜哤atcher绫诲叚銆俈ue鍘熷瀷涓婄殑eventsMixin锛屽畾涔?dollar;on銆?dollar;once銆?dollar;off銆?dollar;emit浜嬩欢鏂规硶锛岃繑鍥瀡m涓冦€俵ifecycleMixin鍦╒ue.prototype涓婂畾涔変簡_update銆?dollar;forceUpdate銆?dollar;destroy鏂规硶鍏€俽enderMixin鍦╒ue鍘熷瀷涓婏紝鍦╒ue鍘熷瀷涓婂畾涔?nextTick鏂规硶锛屽畾涔塤render鏂规硶銆傚€煎緱娉ㄦ剰鐨勬槸锛岃繖涓柟娉曚細璋冪敤vm.$createElement鏉ュ垱寤轰竴涓櫄鎷烡OM銆傚鏋滆繑鍥炲€紇node涓嶆槸铏氭嫙DOM绫诲瀷锛屽垯浼氬垱寤轰竴涓┖鐨勮櫄鎷烡OM銆俈irtualDOM锛歏Node瀹為檯涓婃槸涓€涓被锛岀粨鏋勫涓嬶細classVNode{tag:string|绌虹櫧;鏁版嵁锛歏NodeData|绌虹櫧;瀛╁瓙浠細锛熸暟缁?VNode>锛涙枃鏈細瀛楃涓瞸绌虹櫧;姒嗘爲锛氳妭鐐箌绌虹櫧;绌虹櫧;涓婁笅鏂囷細缁勪欢|绌虹櫧;閿細瀛楃涓瞸缂栧彿|绌虹櫧;缁勪欢閫夐」锛歏NodeComponentOptions|绌虹櫧;componentInstance:缁勪欢|绌虹櫧;鐖惰妭鐐癸細VNode|娉ㄦ剰createElement鏂规硶鏈€缁堝垱寤轰竴涓猇Node銆傜浉鍏崇殑6涓弬鏁板涓嬶細鍙傛暟鍚嶆弿杩癱ontext锛欳omponentvue瀹炰緥瀵硅薄tag锛氫换鎰忔爣绛惧悕锛屽彲浠ユ槸瀛楃涓瞕iv鎴栫粍浠舵爣绛綿ata锛歏NodeData瑙佷笅闈㈡帴鍙NodeDatachildren锛欰rray
