黑马程序员技术交流社区

标题: 【上海校区】Vue在同一组件中,methods中的一个方法调用meth... [打印本页]

作者: 不二晨    时间: 2019-4-15 10:29
标题: 【上海校区】Vue在同一组件中,methods中的一个方法调用meth...
1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

new Vue({
el: '#app',
data: {
  test:111,
},
methods: {
  test1:function(){
   alert(this.test)
  },
  test2:function(){
   alert("this is test2")
   alert(this.test3) //test3调用时弹出undefined
  },
  test3:function(){
   this.$options.methods.test2();//在test3中调用test2的方法
  }
}
})


this.$options.methods.test2();一个方法调用另外一个方法;





欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2