微信小程序调用同页面的自定义函数undefined

不管把function放在onload前面还是后面都报这个错误。后来发现是没有用that。
解决方案:

var  that=this;
if(options.from=="one"){
    
    //说明是从购物车来的,只买一件
        that.data.list.push(that.getProductInfo(options.id));
    }

猜你喜欢

转载自blog.csdn.net/qq_41353397/article/details/111826398