GVKun编程网logo

eslint Cannot read property ''range'' of null错误(eslint null parsing error)

33

关于eslintCannotreadproperty''range''ofnull错误和eslintnullparsingerror的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于Andr

关于eslint Cannot read property ''range'' of null错误eslint null parsing error的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于Android webview vue网页 Uncaught TypeError: Cannot read property ‘getItem‘ of null、angular.min.js:107 TypeError: Cannot read property 'gc' of undefined、AngularJs Type error : Cannot read property 'childNodes' of undefined、Cannot read properties of null (reading ''addEventListener''等相关知识的信息别忘了在本站进行查找喔。

本文目录一览:

eslint Cannot read property ''range'' of null错误(eslint null parsing error)

eslint Cannot read property ''range'' of null错误(eslint null parsing error)

手动添加的配置,2个项目OK,还个项目 运行报错

Cannot read property ''range'' of null
TypeError: Cannot read property ''range'' of null
    at SourceCode.getTokenBefore (/Users/jason/my-project/node_modules/eslint/lib/token-store/index.js:303:17)
    at checkSpacingBefore (/Users/jason/my-project/node_modules/eslint/lib/rules/template-curly-spacing.js:51:42)
    at TemplateElement (/Users/jason/my-project/node_modules/eslint/lib/rules/template-curly-spacing.js:116:17)
    at listeners.(anonymous function).forEach.listener (/Users/jason/my-project/node_modules/eslint/lib/util/safe-emitter.js:47:58)

3个项目eslint的配置包都是相同版本,最后这个报错的解决方案是将

"babel-eslint": "^8.2.1", 改为 "babel-eslint": "8.0.1",
重新install后能正常跑起来了.

 

Android webview vue网页 Uncaught TypeError: Cannot read property ‘getItem‘ of null

Android webview vue网页 Uncaught TypeError: Cannot read property ‘getItem‘ of null

1.问题

在Android 的 webview 中 显示 vue 网页后,发现有个网址传参并没有实现正确的逻辑操作,在页面上显示的结果不一样。
测试网页传参,传参读取正确。测试逻辑运算及其赋值,正确。
发现问题:在网页打印反馈中发现报错:Uncaught TypeError: Cannot read property ‘getItem’ of null

2.原因

getItem是网页上调用localStorage或者sessionStorage在浏览器中读取储存数据时调用的方法。
现在该方法读取的为空,按网页的代码来看如果为空会走其他的方法,但是查看发现为空的情况也没实现,应该的是在读写浏览器的储存数据方面导致问题。查询该报错了解到,Android 的 webview 中默认禁止网页Dom缓存的,所以网页无法读写缓存数据,才导致该问题。(还有人抱怨说前端工程师写的代码不规范,前端可不背锅,iOS和网页都没该问题,话说,Android不也是前端么)。

3.解决

webview 中设置允许缓存数据。


//允许Dom缓存数据
webSettings.setDomStorageEnabled(true); 

4.反思

有问题还得先从调试窗口看起,把报错解决了,别自己臆想些问题原因。先解决了那个报错,岂不能节省很多时间。

angular.min.js:107 TypeError: Cannot read property 'gc' of undefined

angular.min.js:107 TypeError: Cannot read property 'gc' of undefined

1、错误描述

angular.min.js:107 TypeError: Cannot read property ''gc'' of undefined



2、错误原因


3、解决办法

AngularJs Type error : Cannot read property 'childNodes' of undefined

AngularJs Type error : Cannot read property 'childNodes' of undefined

一、在AngularJs和JQuery插件共存咋项目中经常会遇到如下异常

Type error : Cannot read property ''childNodes'' of undefined



解决方案1:

$timeout(init,0);

引用$timeout服务,异步执行JQuery的初始化代码

解决方案2:

angular.element(document).ready(function () {
    //Angular breaks if this is done earlier than document ready.
    setupSliderPlugin();
});
在angularjs初始化视图之后执行JQuery 的绑定

二、在使用Bootstrap-table绑定工具栏是就会遇到如上问题

@*工具栏*@
<div id="toolBar">
    <div>
        <ang-click="addBtnClick()"><i>新建</i></a>
        <a><i>删除</i></a>
    </div>
</div>
<table id="datatable"data-search="true"  
        data-show-refresh="true"  
        data-show-toggle="true"  
        data-show-columns="true"  
        data-toolbar="#toolBar">
</table>
控制器加载成功,绑定列表
//绑定列表
var table = null;
$timeout(function () {
    table = $(''#datatable'').bootstrapTable({
        columns: [
            { field: ''checkBox'',title: ''主键'',checkBox: true },{ field: ''Name'',title: ''角色名称'' },{ field: ''SortValue'',title: ''排序列'' },{
                field: ''IsSys'',title: ''角色分类'',formatter(value,row,index) {
                    if (value)
                        return ''内置角色'';
                    return ''自定义角色'';
                }
            },{
                filed: ''RoleID'',title: ''操作'',index) {
                    var btn = '''';
                    btn += ''<spantitle="编辑"><i></i></span>'';
                    btn += ''<spantitle="权限"><i></i></span>'';
                    return btn;
                }
            }
        ],url: ''/admin/menu/getlist_role'',pagination: true,sidePagination: ''server'',queryParams: function (params) {
            return params;
        }
    });
},0);

更多:
AngularJs ng-bind-html指令整理

angularjs unsafe ng-href using javascript: void(0);

AngularJs $http 请求服务整理

Cannot read properties of null (reading ''addEventListener''

Cannot read properties of null (reading ''addEventListener''

html代码:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Form Submission</title>
    <link href="sytles.css" rel="stylesheet">
    <script src="script.js"></script>
    
</head>
<body>
    <form id="userForm" >
        <div>
            <label for="name" >姓名:</label>
            <input type="text" id="name" name="name" maxlength="30" value="user" placeholder="请输入姓名" required>
        </div>
        <div>
            <label for="password">密码:</label>
            <input type="password" id="password" name="password" value="pass.123" placeholder="请输入密码" required>
        </div>
       <div>
            <!-- 性别选择 -->
            <span>你的性别:</span>
            <label for="male">男</label>
            <input type="radio" id="male" name="gender" value="male" checked required>
            <label for="female">女</label>
            <input type="radio" id="female" name="gender" value="female" required>
       </div>

       <div>
            <span>你的科室:</span>
            <input type="radio" id="soft1" name="soft" value="soft1" checked required>
            <label for="soft1">软一</label>
            <input type="radio" id="soft2" name="soft" value="soft2" required>
            <label for="soft2">软二</label>
            <input type="radio" id="soft3" name="soft" value="soft3" required>
            <label for="soft3">软三</label>
            <input type="radio" id="soft4" name="soft" value="soft4" required>
            <label for="soft4">软四</label>
            <input type="radio" id="soft5" name="soft" value="soft5" required>
            <label for="soft5">软五</label>
       </div>
    
       <div>
            <!-- 使用过的app选择 -->
            <span>使用过的工行app:  </span>
            <input type="checkbox" id="app1" name="apps" value="app1" checked>
            <label for="app1">手机银行</label>
            <input type="checkbox" id="app2" name="apps" value="app1">
            <label for="app2">e生活</label>
            <input type="checkbox" id="app3" name="apps" value="app2">
            <label for="app3">融易联</label>
            <input type="checkbox" id="app4" name="apps" value="app3">
            <label for="app4">e办公</label>
           
            <!-- 可以继续添加更多app -->
       </div>

       <div>
            <!-- 日期选择 -->
            <label for="date">日期:</label>
            <input type="date" id="date" name="date" value="2024-03-01" required>

       </div>

        <!-- Add other form fields here -->
        <div>
            <label for="email">邮箱:</label>
            <input type="email" id="email" name="email" value="123@qq.com" required>
        </div>
        <div>
                        <!-- 城市选择 -->
            <label for="city">城市:</label>
            <select id="city" name="city" required>
                <option value="">请选择城市</option>
                <option value="beijing" selected>北京</option>
                <option value="shanghai">上海</option>
                <option value="guangzhou">广州</option>
                <option value="shenzhen">深圳</option>
                <!-- 可以继续添加更多城市 -->
            </select>
        </div>

        <div>
            <label for="introduction">介绍你自己:</label>
            
            <div>
                <textarea id="introduction" name="introduction"  required>测试内容</textarea>
            </div>
            <div>
                <button type="submit">Submit</button>
                <input type="reset" value="重置">
            </div>
        </div>

    </form>
</body>
</html>

js代码:

function formDataToJson(formData) {
  let obj = {};
  for (let key of formData.keys()) {
    obj[key] = formData.get(key);
  }
  return JSON.stringify(obj);
}



Object.defineProperty(HTMLFormElement.prototype, ''jsondata'', {
  get() {
      const jsondata = {}
      const formdata = new FormData(this);
      formdata.forEach((value, key) => {
          if (!jsondata[key]) {
              jsondata[key] = formdata.getAll(key).length > 1 ? formdata.getAll(key) : formdata.get(key);
          }
      });
      return jsondata;
  }
})

Object.defineProperty(HTMLFormElement.prototype, ''formdata'', {
  get() {
      return new FormData(this);
  }
})


document.getElementById(''userForm'').addEventListener(''submit'', function(event){
  event.preventDefault(); // 阻止表单默认提交行为

  const formData = new FormData(this);
  const entries = Object.fromEntries(formData.entries());
  console.log("2312");
  let jsonData = formDataToJson(formData);
  console.log(jsonData)
  //console.log(entries); // 打印表单数据到控制台 
  
});

使用浏览器渲染后控制台报错:
image.png

script.js:31 Uncaught TypeError: Cannot read properties of null (reading ''addEventListener'')
    at script.js:31:36

原因:脚本<script>>在head中,在body还没加载完之前,脚本先加载了,所以找不到监听对象

解决方法: 将脚本放在<body>里或者<body>后

修改后的html代码:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Form Submission</title>
    <link href="sytles.css" rel="stylesheet">
    
</head>
<body>
    <form id="userForm" >
        <div>
            <label for="name" >姓名:</label>
            <input type="text" id="name" name="name" maxlength="30" value="user" placeholder="请输入姓名" required>
        </div>
        <div>
            <label for="password">密码:</label>
            <input type="password" id="password" name="password" value="pass.123" placeholder="请输入密码" required>
        </div>
       <div>
            <!-- 性别选择 -->
            <span>你的性别:</span>
            <label for="male">男</label>
            <input type="radio" id="male" name="gender" value="male" checked required>
            <label for="female">女</label>
            <input type="radio" id="female" name="gender" value="female" required>
       </div>

       <div>
            <span>你的科室:</span>
            <input type="radio" id="soft1" name="soft" value="soft1" checked required>
            <label for="soft1">软一</label>
            <input type="radio" id="soft2" name="soft" value="soft2" required>
            <label for="soft2">软二</label>
            <input type="radio" id="soft3" name="soft" value="soft3" required>
            <label for="soft3">软三</label>
            <input type="radio" id="soft4" name="soft" value="soft4" required>
            <label for="soft4">软四</label>
            <input type="radio" id="soft5" name="soft" value="soft5" required>
            <label for="soft5">软五</label>
       </div>
    
       <div>
            <!-- 使用过的app选择 -->
            <span>使用过的工行app:  </span>
            <input type="checkbox" id="app1" name="apps" value="app1" checked>
            <label for="app1">手机银行</label>
            <input type="checkbox" id="app2" name="apps" value="app1">
            <label for="app2">e生活</label>
            <input type="checkbox" id="app3" name="apps" value="app2">
            <label for="app3">融易联</label>
            <input type="checkbox" id="app4" name="apps" value="app3">
            <label for="app4">e办公</label>
           
            <!-- 可以继续添加更多app -->
       </div>

       <div>
            <!-- 日期选择 -->
            <label for="date">日期:</label>
            <input type="date" id="date" name="date" value="2024-03-01" required>

       </div>

        <!-- Add other form fields here -->
        <div>
            <label for="email">邮箱:</label>
            <input type="email" id="email" name="email" value="123@qq.com" required>
        </div>
        <div>
                        <!-- 城市选择 -->
            <label for="city">城市:</label>
            <select id="city" name="city" required>
                <option value="">请选择城市</option>
                <option value="beijing" selected>北京</option>
                <option value="shanghai">上海</option>
                <option value="guangzhou">广州</option>
                <option value="shenzhen">深圳</option>
                <!-- 可以继续添加更多城市 -->
            </select>
        </div>

        <div>
            <label for="introduction">介绍你自己:</label>
            
            <div>
                <textarea id="introduction" name="introduction"  required>测试内容</textarea>
            </div>
            <div>
                <button type="submit">Submit</button>
                <input type="reset" value="重置">
            </div>
        </div>

    </form>
</body>
<!-- 把script放在body之后再加载 -->
<script src="script.js"></script>
</html>

我们今天的关于eslint Cannot read property ''range'' of null错误eslint null parsing error的分享已经告一段落,感谢您的关注,如果您想了解更多关于Android webview vue网页 Uncaught TypeError: Cannot read property ‘getItem‘ of null、angular.min.js:107 TypeError: Cannot read property 'gc' of undefined、AngularJs Type error : Cannot read property 'childNodes' of undefined、Cannot read properties of null (reading ''addEventListener''的相关信息,请在本站查询。

本文标签: