In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the javascript fast application stack overflow how to do, the article is very detailed, has a certain reference value, interested friends must read it!
A short code snippet describes the problem where $element ('id') is assigned to a member variable and a stack overflow occurs, as well as a solution to fix it.
When assigning the acquired content $element ('id') to a member variable, RangeError: Maximum call stack size exceeded may have a stack overflow (), causing the program to crash. A stack overflow also occurs if a member variable reference exists in a DOM and the member variable changes. The sample code is as follows:
{{stateText}} export default {private: {mContentNode: null, stateText: 'init state'}, onReady () {/ * When data obtained by $element (' id') is assigned to a member variable, a stack overflow may occur. * / this.mContentNode = this.$element ('content')}, onTestClick () {/ * To reproduce this problem, change a member variable when member variable references exist for a DOM. * / this.stateText = 'new state'}}
The reason is that assignment can lead to massive changes in data. This results in an internal exception loop, resulting in a stack overflow.
Solution
To prevent stack overflows, you can assign the acquired data to $element ('id') local or global variables instead of member variables. The sample code is as follows:
Let $gContentNode = null export default {private: {stateText: 'init state'}, onReady () {/ * You can assign the data obtained through $element (' id') to a local or global variable to prevent the stack overflow. * / const cContentNode = this.$element ('content') $gContentNode = this.$element (' content')}, onTestClick () {this.stateText = 'new state'}} these are all the contents of the article "what to do about stack overflow in fast applications in javascript". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.