const app = getApp()

Page({
        data: {
                str: '你猜',
                multiArray: [], // 二维数组数据
                arr1: ['a', 'b', 'c'],
                arr2: [
                        [1, 2, 3],
                        [4, 5, 6],
                        [7, 8, 9]
                ],
                multiIndex: [0, 0], // 默认的下标
        },
        start() {
                let arr1 = this.data.arr1
                let arr2 = this.data.arr2
                this.setData({
                        multiArray: [arr1, arr2[0]]
                })
        },
        change(e) {
                console.log(e.detail)
                let column = e.detail.column
                let data = {
                        multiIndex: this.data.multiIndex,
                        multiArray: this.data.multiArray
                }
                data.multiIndex[column] = e.detail.value;
                switch (column) {
                        case 0:
                                data.multiArray[1] = this.data.arr2[e.detail.value]
                                data.multiIndex[1] = 0
                                break;
                }
                this.setData(data)
        },
        get_str(e) {
                console.log(e)
                let index1 = e.detail.value[0]
                let index2 = e.detail.value[1]

                let str2 = this.data.arr2[index1][index2]
                console.log(str2)
                this.setData({
                        str: str2
                })
        },
        onLoad: function() {
                this.start()
        },
})