在IE 11上运行AngularJs(1.6)应用程序时遇到问题,当用户输入一些文本和表情符号图标时,它崩溃并关闭了浏览器。 10-20次中有2次遇到问题。我被怀疑存在内存泄漏,但与此同时,如果“应用程序”不需要用户输入,则不会崩溃。 我想知道是否有人可以帮助我。
图书馆:
<script src="js/lib/jquery.js"></script>
<script src="js/lib/lodash.min.js"></script>
<script src="js/lib/angular.min.js"></script>
<script src="js/lib/emoji-picker.min.js"></script>
<script src="js/lib/rzslider.min.js"></script>
<script src="js/lib/angular-rating-icons.js"></script>
<script src="js/lib/ui-bootstrap-tpls.min.js"></script>
用户输入部分:
<div ng-if="showInput" class="slide-top" id="inputBox">
<div class="inputMessageHeader" ng-i18next="chatbot.userinput.title" ng-attr-style="background-color: {{primaryColor}}" style="background-color: {{primaryColor}}"></div>
<form class="full-height">
<div layout="row">
<div flex id="inputUser">
<textarea maxlength="2000"
ng-model="components[currentQaIndex].usrMessage"
ng-i18next="[placeholder]chatbot.userinput.placeholder"
rows="5" ng-keyup="countCharacters()"
ng-change="hideEmojiPicker()">
</textarea>
<div class="counter"><span ng-class="{error: components[currentQaIndex].usrMessage.length > 2000}"> {{components[currentQaIndex].usrMessage.length || 0}} </span> / 2000</div>
</div>
<div id="gifArea" ng-if="messageGifUrl" flex="45">
<img ng-src="{{messageGifUrl}}" />
<md-button id="gifEdit" ng-click="toggleGifPopup()" aria-label="edit" class="md-icon-button launch fa fa-pencil-square-o"></md-button>
<md-button id="gifDelete" ng-click="deleteGif()" aria-label="delete" class="md-icon-button launch fa fa-trash-o"></md-button>
</div>
</div>
<div id="separatorLine"></div>
<div class="form-action">
<div class="gif-btns">
<div emoji-picker="components[currentQaIndex].usrMessage" title="Emoji" placement="top" output-format="unicode" class="emoji" ng-click="toggleEmojiPicker()" ng-class="{active: emojiVisible}" on-change-func="hideEmojiPicker">
</div>
<span class="gif" ng-click="toggleGifPopup()" ng-class="{active: gifPopupVisible}"></span>
<span class="gallery"></span>
<span class="camera"></span>
</div>
<div class="btns" >
<span ng-i18next="chatbot.calltoactions.cancel" class="blink-btn" ng-attr-style="color: {{primaryColor}}; border-bottom-color: {{primaryColor}}" style="color: {{primaryColor}}; border-bottom-color: {{primaryColor}}" ng-mouseenter="setDarkerColor($event)" ng-mouseleave="setPrimaryColor($event)" ng-click="onCancelQuestion()" ng-if="isOther" ></span>
<span ng-i18next="chatbot.calltoactions.ok" class="blink-btn" ng-attr-style="color: {{primaryColor}}; border-bottom-color: {{primaryColor}}" style="color: {{primaryColor}}; border-bottom-color: {{primaryColor}}" ng-mouseenter="setDarkerColor($event)" ng-mouseleave="setPrimaryColor($event)" ng-click="onSaveUserMessage($event)" ng-if="isOther"></span>
<span ng-i18next="chatbot.calltoactions.validate" class="blink-btn" ng-attr-style="color: {{primaryColor}}; border-bottom-color: {{primaryColor}}" style="color: {{primaryColor}}; border-bottom-color: {{primaryColor}}" ng-mouseenter="setDarkerColor($event)" ng-mouseleave="setPrimaryColor($event)" ng-click="onSubmitAnswer($event)" ng-if="!isOther"></span>
<span ng-i18next="chatbot.calltoactions.skip" class="blink-btn" ng-attr-style="color: {{primaryColor}}; border-bottom-color: {{primaryColor}}" style="color: {{primaryColor}}; border-bottom-color: {{primaryColor}}" ng-mouseenter="setDarkerColor($event)" ng-mouseleave="setPrimaryColor($event)" ng-click="onSkipQuestion($event)" ng-if="components[currentQaIndex].options.is_skippable && !isOther" ></span>
</div>
</div>
</form>
</div>
答案 0 :(得分:0)
您在用户输入上有一些错误的代码,这就是我从您的发言中得出的唯一结论。发布一些代码或检查您的用户输入,您可能正在执行一些循环或递归操作,或者摘要周期过多。顺便说一句,您可以在其他浏览器上重复和复制吗?输入输入时,请注意IE上的内存和CPU使用情况。除非角度被破坏,否则您的身体已经有些碎裂了。但是,我不会得出这个结论。
<textarea maxlength="2000" ng-model="components[currentQaIndex].usrMessage"
ng-i18next="[placeholder]chatbot.userinput.placeholder" rows="5"
ng-keyup="countCharacters()" ng-change="hideEmojiPicker()">
</textarea>
在此处使用某种ng-model-option
进行反跳。什么是countCharacters?您可以在模型上执行.length或使用$viewValue.length
,但我看不到有什么大不了的地方,可以进行一些优化,但此处完全没有死。在chrome和其他浏览器中对此进行测试,并使用断点和日志记录来查看其崩溃的原因。