处理边界情况-访问根实例

Vue.component('visit-root',{
      template:`
        <div>
          <div>{
   
   {this.$root.foo}}</div>
          <div>{
   
   {this.$root.two =12}}</div>
        </div>
      `
    })
    new Vue({
      el:"#demo",
      data:{
        foo:1,
        two:12
      },
      computed:{
        bar:function(){
          console.log("bar")
        }
      },
      methods:{
        baz:function(){
          console.log("baz")
        }
      }
    })

参考:https://www.cnblogs.com/gongshunfeng91/p/11301497.html

猜你喜欢

转载自blog.csdn.net/u012687612/article/details/112826756