<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                #### mvvm ![https://upload-images.jianshu.io/upload_images/3360875-0165a2d4e529f192.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700](https://upload-images.jianshu.io/upload_images/3360875-0165a2d4e529f192.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700) viewModel是整個vue實例 vue在編譯階段會識別出所有綁定在元素(通過 el 屬性傳入)上的指令。 link 過程中,建立這些指令與對應數據(通過 data 屬性傳入初始值)的watcher。watcher會在dep上添加訂閱者,observe用來監聽所有屬性的變化,告知dep,由dep分發給每個watcher,再由watcher更新view。 雙向綁定:數據劫持加收發訂閱模式 數據劫持:defineProperty ``` //數據劫持 function defineReactive (obj, key, val) { var dep = new Dep(); Object.defineProperty(obj, key, { get: function() { //添加訂閱者watcher到主題對象Dep if(需要添加訂閱者) { // JS的瀏覽器單線程特性,保證這個全局變量在同一時間內,只會有同一個監聽器使用 dep.addSub(watcher); } return val; }, set: function (newVal) { if(newVal === val) return; val = newVal; console.log(val); // 作為發布者發出通知 dep.notify(); } }) } //observe function observe(this.data) { Object.keys(obj).forEach(function(key) { defineReactive(this.data, key, this.data[key]); }) } //dep負責發送通知 function Dep() { this.subs = []; } Dep.prototype = { addSub: function(sub) { this.subs.push(sub); }, notify: function() { this.subs.forEach(function(sub) { sub.update(); }) } } ``` #### vue-router鉤子函數 ``` 全局 router.beforeEach((to, from, next) //跳轉前 router.afterEach //跳轉后 組件內 beforeRouteEnter beforeRouteUpdate (2.2 新增) beforeRouteLeave 路由配置里 beforeEnter ``` 指令:v-if、v-show、v-for、v-bind、v-on、v-model 自定義指令: ``` Vue.directive(name, { //binding包括name\value\expression\arg等 bind(el, binding, vnode) {指令第一次綁定到元素時} inserted(e, b, v) {被綁定元素插入父節點時調用} update(e, b, v) {所在組件的 VNode 更新時調用} 等等 }) export default { name:'', directives: { name: { bind() {} xxx } } } ``` 組件通信 ``` 父子 props傳遞 子組件$emit(name, args),父級@name($event) 父級通過ref訪問子組件實例 同級之間使用bus或者vuex var bus = new Vue(); component1 bus.$emit('id-selected', 1) component2 bus.$on('id-selected', id => {}) ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看