<picker bindchange="XS_Model" value="{{XS_Model_index}}" range="{{XS_Model_array}}">
<view class="XS_Model_picker">
梯型:{{XS_Model_array[XS_Model_index]}}
</view>
</picker>
<button class="TJ_third" bindtap="TJ_third">确认</button>
<picker bindchange="XS_Model" value="{{XS_Model_index}}" range="{{XS_Model_array}}">
<view class="XS_Model_picker">
梯型:{{XS_Model_array[XS_Model_index]}}
</view>
</picker>
//1.ts
data: {
XS_Model:'',
XS_Model_array: ['ML-PE02', 'ML-PE01', 'ML-K', 'ML-WK'],
XS_Model_index: 0,
},
XS_Model(e) {
const { XS_Model_array = [] } = this.data
const { detail: { value: XS_Model_index = 0 } = {} } = e
const XS_Model = XS_Model_array[XS_Model_index]
this.setData({
XS_Model,
XS_Model_index
})
//怎么赋值给下一个页面这边不知道该怎么写了
},
//2.ts //页面1将数据传递到页面2,同时页面2的选项与1相同
data: {
XS_Model:'',
XS_Model_array: ['ML-PE02', 'ML-PE01', 'ML-K', 'ML-WK'],
XS_Model_index: 0,
},
XS_Model(e) {
const { XS_Model_array = [] } = this.data
const { detail: { value: XS_Model_index = 0 } = {} } = e
const XS_Model = XS_Model_array[XS_Model_index]
this.setData({
XS_Model,
XS_Model_index
})
//这里如何接收上一个页面传递过来的值并显示
有四种方式传递
1. 存储到数据缓存 https://developers.weixin.qq.com/miniprogram/dev/api/storage/wx.setStorageSync.html
2. 通过App存放全局变量
3. 通过跳转URL数据传递,如果是对象的话需要先通过JSON.stringify(obj)将object对象转换为JSON字符串,并返回该字符串,再到接收页面JSON.parse解析。
4. 通过事件通信通道 https://developers.weixin.qq.com/miniprogram/dev/api/route/EventChannel.html