帖子
帖子
用户
博客
课程
显示全部楼层
15
帖子
0
勋章
138
Y币

[云开发] 刚刚开始用avm,请问methods中定义的函数间怎么调用

[复制链接]
发表于 2022-8-19 15:41:31
  1. methods:{
  2.                 reloadListView(){
  3.                         var UIListView = api.require('UIListView');
  4.                         UIListView.reloadData({
  5.                                 data: this.userlist
  6.                         }, function (ret) {
  7.                                 if (ret) {
  8.                                         //如何调用other方法        
  9.                                 }
  10.                         });
  11.                 },other(){

  12.                 }
  13.         }
复制代码


380
帖子
4
勋章
6
Y币
this.方法名 ()
15
帖子
0
勋章
138
Y币
这种方式只能在函数内使用,函数内又定义的回调函数中就不行了。
15
帖子
0
勋章
138
Y币
已经解决了
通过在方法的最前面声明个变量  var p=this;
在子函数快中使用p.other() 即可
15
帖子
0
勋章
138
Y币
自已搞定了,解决方式如下:

  1. methods:{
  2.                 reloadListView(){
  3. var p=this;
  4.                         var UIListView = api.require('UIListView');
  5.                         UIListView.reloadData({
  6.                                 data: this.userlist
  7.                         }, function (ret) {
  8.                                 if (ret) {
  9.                                         //如何调用other方法        
  10. p.other();
  11.                                 }
  12.                         });
  13.                 },other(){

  14.                 }
  15.         }
复制代码
可以的哈
您需要登录后才可以回帖 登录

本版积分规则