代码里面不能这样写_self.$parent.$parent.$parent
这样写会导致报错:
22:00:28.277 estrusunit init
22:00:28.307 thirdScriptError
22:00:28.307 undefined is not an object (evaluating '_self.$parent.$parent.$parent');at "pages/estrus/list" page lifeCycleMethod onLoad function
22:00:28.307 getListData
22:00:28.307 created
22:00:28.307 callHook
22:00:28.307 _init
22:00:28.307 VueComponent
22:00:28.307 createComponentInstanceForVnode
22:00:28.307 init
22:00:28.307 createComponent
22:00:28.307 createElm
22:00:28.307 createChildren
22:00:28.307 createElm
22:00:28.307 createChildren
22:00:28.307 createElm
22:00:28.307 patch
22:00:28.307 patch
22:00:28.307 _update
22:00:28.307 updateComponent
22:00:28.307 get
22:00:28.307 Watcher
22:00:28.307 mountComponent
22:00:28.307 onLoad
22:00:28.307 [native code]
22:00:28.307 uniappservice.html:2:803684
22:00:28.307 [native code]
22:00:28.307 G4P@uniappservice.html:2:773814
22:00:28.307 f4P@uniappservice.html:2:774799
22:00:28.307 V0P@uniappservice.html:2:776683
22:00:28.307 uniappservice.html:2:780477
22:00:28.307 uniappservice.html:2:788022
22:00:28.307 uniappservice.html:2:296369
22:00:28.307 forEach@[native code]
22:00:28.307 uniappservice.html:2:296351
22:00:28.307 uniappservice.html:2:241395
22:00:28.307 b1o@uniappservice.html:2:101426
22:00:28.307 m1@uniappservice.html:2:2588
22:00:28.307 g4@uniappservice.html:2:44469
22:00:28.307 u5@uniappservice.html:2:98399
22:00:28.307 i1o@uniappservice.html:2:100461
22:00:28.307 y1o@uniappservice.html:2:100941
22:00:28.307 Z0A@uniappservice.html:2:234788
22:00:28.307 T0A@uniappservice.html:2:236129
22:00:28.307 N2s@uniappservice.html:2:294075
22:00:28.307 uniappservice.html:2:241395
22:00:28.307 Q8S@uniappservice.html:2:202238
22:00:28.307 promiseApi
22:00:28.307 changeCategory
22:00:28.307 click
22:00:28.307 handleProxyWithVue
22:00:28.307 handleProxy@[native code]
22:00:28.307 uniappservice.html:2:619753
22:00:28.307 uniappservice.html:2:715654
22:00:28.317 uniappservice.html:2:718637
22:00:28.317 b1o@uniappservice.html:2:101426
22:00:28.317 G0@uniappservice.html:2:98252
22:00:28.317 uniappservice.html:1:291
22:00:28.317 uniappservice.html:2:207418
22:00:28.317 uniappservice.html:2:413096
22:00:59.347 App Hide
子组件调用父组件中的变量,或者改变父组件的变量的值!代码写法
..............
methods: {
getListData() {
_self = this;
let url = common.websiteUrl + route_prefix.faqing_unDisposeList + 'start=' + _self.$parent.$parent.$parent.page +
'&limit=' +
route_prefix.pageSize;
let header = common.getHeaders();
uni.request({
url: url,
header: header,
dataType: "json",
method: "GET",
success: function(res) {
....................
6 个回复
1***@qq.com
children 访问不到root层,$parent是undefined,有人知道为啥么
z***@outlook.com
同问....
8***@qq.com
同问
BOOGEYMAN
+1
[已删除]
只缺前端的可找我;
整个项目外包也可找我;
wx、tel(13070273424)
月子巨
uniapp中有个getCurrentPages()可以获得页面栈,可以打印一下看下,页面栈里面包含了父组件所有的data和methods方法,可以用此代替$parent