<picker bindchange="handleChange" value="{{index}}" range="{{array}}">
<view class="picker">
当前选择:{{array[index]}}
</view>
</picker>
Page({
data: {
array: ['直管', '弯管', '弯头', '异径管'],
objectArray: [
{
id: 0,
name: '直管'
},
{
id: 1,
name: '弯管'
},
{
id: 2,
name: '弯头'
},
{
id: 3,
name: '异径管'
}
]
},
handleChange(e) {
const value = e.detail.value; // 获取picker的value值
this.setData({
index: value, // 更新index的值
});
// 根据value值跳转到对应的页面
switch (value) {
case 0:
wx.navigateTo({
url: '/pages/page1/page1',
});
break;
case 1:
wx.navigateTo({
url: '/pages/page2/page2',
});
break;
// 其他选项的跳转逻辑
case 2:
wx.navigateTo({
url: '/pages/page3/page3',
});
break;
case 3:
wx.navigateTo({
url: '/pages/page4/page4',
});
break;
}
},
});
实现不了页面跳转,是为什么
/pages 前面的斜杠去掉试试