0

我在 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>
4

1 回答 1

0

您在用户输入上有一些错误的代码,这是我可以从您所说的内容中得出的唯一结论。发布一些代码或检查您的用户输入,您可能正在执行一些循环或递归或过多的摘要循环。顺便说一句,您可以在其他浏览器上重复和复制吗?输入输入时观察 IE 上的内存和 CPU 使用情况。除非 angular 坏了,否则你会遇到一些事情;但是,我不会贸然下这个结论。

更新

<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-optionwith debounce 。什么是countCharacters?您可以在模型上执行 .length 或使用$viewValue.length我没有发现任何重大错误,可以进行一些优化,但这里没有什么应该完全消失。在 chrome 和其他浏览器中对此进行测试,并使用断点和日志记录来查看其崩溃的原因。

于 2018-06-25T16:40:51.560 回答