美文网首页
1.10、多个vue对象,相互调用

1.10、多个vue对象,相互调用

作者: flyjar | 来源:发表于2021-08-09 09:49 被阅读0次

十、多个vue对象,相互调用

<script>  
 var v1=new Vue({
      el:"#app",//div的id
      data:{
          name:"小明"
      },
      methods:{
          //方法中有默认参数,event,通过event.target可以拿到绑定此事件的标签
          methodTest(){
             alert("方法测试");
          }
      }
});
  var v2=new Vue({
      el:"#app2",//div的id
      data:{
          age:11
      },
      methods:{
          //方法中有默认参数,event,通过event.target可以拿到绑定此事件的标签
          app2MethodTest(event){
            v1.methodTest();
            v1.name="大明";
          }
      }
});
</script>

相关文章

网友评论

      本文标题:1.10、多个vue对象,相互调用

      本文链接:https://www.haomeiwen.com/subject/hzvntltx.html