我写了一个测试导航的程序:
<view>
<navigator url=’…/…/pages/i/first’ hover-class=‘navigator-hover’>ScrollView</navigator>
<navigator url=’…/…/pages/swiper/sw’ hover-class=‘navigator-hover’>swiper</navigator>
</view>
app.json代码:
{
“pages”:[
“pages/navigate/navi”,
“pages/i/first”,
“pages/swiper/sw”
]
}
导航的第一个页面"pages/i/first",是一个测试scroll-view的页面,代码如下:
<view>
<scroll-view
scroll-y=“true”
upper-threshold=“20”
bindscrolltoupper=“scrolltoupperFun”
lower-threshould=“30”
bindscrolltolower=“scrolltolowerFun”
scroll-into-view=’{{intoView}}’
style=‘height:600rpx’
>
<view id=‘v1’ style=‘height:300rpx;text-align:center;background-color:cadetblue;’>
这里是视图内容1
</view>
<view id=‘v2’ style=‘height:500rpx;text-align:center;background-color:darkkhaki;’>
这里是视图内容2
</view>
<view id=‘v3’ style=‘height:600rpx;text-align:center;background-color:indianred;’>
这里是视图内容3
</view>
</scroll-view>
<button bindtap=‘scrollToV1’ >滚动到v1</button>
<button bindtap=‘scrollToV2’ >滚动到v2</button>
<button bindtap=‘scrollToV3’ >滚动到v3</button>
</view>
导航到该页面后,第一个按钮点击后事件处理程序不起反应,console提示:
Do not have scrollToV1 handler in current page: pages/i/first. Please make sure that scrollToV1 handler has been defined in pages/i/first, or pages/i/first has been added into app.json
t.warn @ WAService.js:9
N @ WAService.js:8
(anonymous) @ WAService.js:8
(anonymous) @ WAService.js:9
(anonymous) @ WAService.js:4
e.(anonymous function) @ WAService.js:4
d @ appservice:16
g.registerCallback @ appservice:16
k.forEach @ appservice:16
d @ appservice:16
h.onmessage @ appservice:16
但是,当把app.json改成:
{
“pages”:[
”pages/i/first",
“pages/navigate/navi”,
“pages/swiper/sw”
]
}
后,即把它放到首页后,事件处理程序就正常了