Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple initValue will throw error 'Cannot read properties of undefined ' #112

Open
349989153 opened this issue Oct 25, 2023 · 1 comment

Comments

@349989153
Copy link

      let mySelect = new MobileSelect({
        trigger: '#city1',
        wheels: [
          {data:[{id: '1', value:'周日'}, {id: '2',value:'周一'}]},
          {data:[{id: '3', value: '08:00'}, {id: '4', value: '09:00'}]}
        ],
        initValue: "周一 09:00",
        keyMap: {
          id: "id",
          value: "value",
        },
      });

and it throws

mobile-select.umd.js:7 Uncaught TypeError: Cannot read properties of undefined (reading 'undefined')
    at mobile-select.umd.js:7:5066
    at Array.reduce (<anonymous>)
    at u.getPositionByInitValue (mobile-select.umd.js:7:4963)
    at u.init (mobile-select.umd.js:7:2729)
    at new u (mobile-select.umd.js:7:1805)
    at HTMLDocument.<anonymous> (test.html?_ijt=lkl8j1rfu6860ah28plbh3dh4s&_ij_reload=RELOAD_ON_SAVE:69:22)
    at c (jquery.min.js:3:7857)
    at Object.fireWith [as resolveWith] (jquery.min.js:3:8658)
    at Function.ready (jquery.min.js:3:3266)
    at HTMLDocument.H (jquery.min.js:3:695)

use:
mobile-select v1.4.0
mobile-select.umd.js

@349989153
Copy link
Author

349989153 commented Oct 25, 2023

      let mySelect = new MobileSelect({
        trigger: '#city1',
        wheels: [
          {data:[{id: '1', value:'周日'}, {id: '2',value:'周一'}]},
          {data:[{id: '1', value: '08:00'}, {id: '2', value: '09:00'}]}
        ],
        connector: ',', // add connector
        initValue: "周一 08:00",
        keyMap: {
          id: "id",
          value: "value",
        },
      });

And if I add connector prop, then the error will be gone, however, the position of each wheel is still wrong

@349989153 349989153 changed the title Simple initValue Error 'Cannot read properties of undefined ' Simple initValue will throw Error 'Cannot read properties of undefined ' Oct 25, 2023
@349989153 349989153 changed the title Simple initValue will throw Error 'Cannot read properties of undefined ' Simple initValue will throw error 'Cannot read properties of undefined ' Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant