zoukankan      html  css  js  c++  java
  • 前端页面使用ace插件优化脚本

    html页面:<pre id="editor" style=" 100%;height: 800px;"></pre>(注:必须设置高度)

    function getScriptHightLight(){
      ace.config.set("basePath", "vendors/ace-build/src-min");
      ace.require("ace/ext/beautify");
      var editor = ace.edit("editor");
      if($scope.store&&$scope.store.scriptContent){
        editor.setValue($scope.store.scriptContent); //设置内容
        if($scope.oper==="detail"){
          editor.setReadOnly(true); //只读
        }else{
          editor.setReadOnly(false); //只读
        }
      }else{
        editor.setValue('');//没有值设置为空
      }
      editor.setOption("wrap", "free") //自动换行
      editor.setShowPrintMargin(false); //设置打印线
      editor.session.setMode("ace/mode/sh");
      editor.setTheme("ace/theme/vibrant_ink"); //引入的模板
      editor.setHighlightActiveLine(true); //设置高亮
      editor.setOptions({
        enableBasicAutocompletion: true,
        enableSnippets: true,
        enableLiveAutocompletion: true
      });
      editor.on('change', function () {//更新脚本事件
        $timeout(function () {
          $scope.$apply(function () {
            var value = editor.getValue();
            $scope.store.scriptContent=value;
          });
        });
      });
    }

  • 相关阅读:
    hotmail 收不到邮件的问题
    getaddrinfo 报错 Invalid value for ai_flags
    Avoiding Common Networking Mistakes
    关掉标准输出
    不需要 root 权限的 ping
    select 的问题
    Behavior Tree 用 Lua 实现一个最简行为树
    对 UDP 的一些思考
    Windows UDP sockets: recvfrom() fails with error 10054
    和等于某个数的所有组合
  • 原文地址:https://www.cnblogs.com/shixy1617/p/10616334.html
Copyright © 2011-2022 走看看