admin管理员组

文章数量:1323348

I receive this error on console Uncaught TypeError: Cannot read property 'querySelectorAll' of undefined ionic.bundle.js:2800 when i go from other view using ionic, but I don't know that is means, and how to solve it

I receive this error on console Uncaught TypeError: Cannot read property 'querySelectorAll' of undefined ionic.bundle.js:2800 when i go from other view using ionic, but I don't know that is means, and how to solve it

Share Improve this question edited Sep 30, 2018 at 23:58 Chris 4,74813 gold badges55 silver badges97 bronze badges asked Sep 30, 2018 at 23:54 Higor TavaresHigor Tavares 671 gold badge2 silver badges11 bronze badges 1
  • 1 it means that something is undefined and isn't expected to be - what part of your code triggers this error (some container is undefined) - an image of the error message is not required - there's something wrong with your code – Jaromanda X Commented Sep 30, 2018 at 23:55
Add a ment  | 

1 Answer 1

Reset to default 4

Disclaimer: I do not have much experience with ionic, this is based upon my experience with general JavaScript.

What your error likely es from is that a specific element that the code relies on, which can't be found when you switch views. I gathered this from querySelectorAll being a property of an Element. It is used to get an child element by the provided CSS Selector. It is frequently used as document.querySelectorAll to get any element on the page that matches the query.

From what you're given us, it appears that your code(or the library internally) is trying to use querySelectorAll on an element in a specific view every time the view changes, regardless of whether it's the view that contains the element or not. This inevitably resulting in the specific element being undefined, and hence not having the querySelectorAll property. Here's some mock code that'd result in roughly the same problem as you have.

# This would be run every time the view changes. 
let myElement = document.querySelectorAll('#element-in-different-view');
myElement === undefined; // true

myElement.querySelectorAll('#foo');
// undefined is not an Element, and as such doesn't have the property `querySelectorAll`

Important Note: As a munity, we can provide you with more specific answers if you include the full traceback you get and a mvce.

本文标签: javascriptCannot read property 39querySelectorAll39 of undefinedStack Overflow