var pages = getCurrentPages(); // 获取页面栈
var prevPage = pages[pages.length - 2]; // 上一个页面
prevPage.$vm.saveUsage(data);
uni.navigateBack({
delta: -1
});
- 发布:2020-05-31 20:00
- 更新:2020-10-19 11:28
- 阅读:4451
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: 10
HBuilderX类型: 正式
HBuilderX版本号: 2.7.9
手机系统: Android
手机系统版本号: Android 10
手机厂商: 华为
手机机型: nova5
页面类型: vue
打包方式: 云端
项目创建方式: HBuilderX
示例代码:
操作步骤:
var pages = getCurrentPages(); // 获取页面栈
var prevPage = pages[pages.length - 2]; // 上一个页面
prevPage.$vm.saveUsage(data);
uni.navigateBack({
delta: -1
});
var pages = getCurrentPages(); // 获取页面栈
var prevPage = pages[pages.length - 2]; // 上一个页面
prevPage.$vm.saveUsage(data);
uni.navigateBack({
delta: -1
});
预期结果:
页面A打开页面B,通过页面B代码调用页面A方法传参
页面A打开页面B,通过页面B代码调用页面A方法传参
实际结果:
prevPage.$vm.saveUsage is not a function. (In 'prevPage.$vm.saveUsage(data)', 'prevPage.$vm.saveUsage' is undefined)
prevPage.$vm.saveUsage is not a function. (In 'prevPage.$vm.saveUsage(data)', 'prevPage.$vm.saveUsage' is undefined)
bug描述:
页面A打开页面B,通过页面B代码调用页面A方法传参,超过一次后显示错误。
var pages = getCurrentPages(); // 获取页面栈
var prevPage = pages[pages.length - 2]; // 上一个页面
prevPage.$vm.saveUsage(data);
uni.navigateBack({
delta: -1
});
第一次执行没错,第二次时报错:
prevPage.$vm.saveUsage is not a function. (In 'prevPage.$vm.saveUsage(data)', 'prevPage.$vm.saveUsage' is undefined)
[Vue warn]: Property or method "toJSON" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.
20:06:22.434 (found in <Root>)
20:06:22.465 [Vue warn]: Property or method "toJSON" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.
20:06:22.527 (found in <Root>)
2 个回复
1***@qq.com - 95后IT男孩
同样的问题,你有没有解决这个
蹦豆儿
同问,如何解决的?