admin管理员组文章数量:1323524
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 (somecontainer
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
1 Answer
Reset to default 4Disclaimer: 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
版权声明:本文标题:javascript - Cannot read property 'querySelectorAll' of undefined - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742132458a2422223.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论