JavaScript:JSLint抛出“只读” [英] JavaScript: JSLint throws "Read Only

查看:101
本文介绍了JavaScript:JSLint抛出“只读”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码:

注意:Slider对象已声明但在下面的代码段中省略,以提高可读性

My code:
note: the Slider Object is declared but omitted in the snippet below for better readability

"use strict";
/*global arrayContainer, SliderInstance, DomObjects */
arrayContainer = new Slider.constructArray();
SliderInstance = Object.beget(Slider);
DomObjects = {

    animationContainer: document.getElementById('animationContainer'),
    buttonRight: document.getElementById('buttonRight'),
    buttonRightDots: document.getElementById('buttonRightDots'),
    ieEffectImg: document.getElementById('ie_effectIMG')        
};



这是JSLint生成的(以及另外两个对象SliderInstance)和DomObjects)


This is what JSLint produces (and on the other two Objects SliderInstance and DomObjects)

Error:
Problem at line 3 character 1: Read only.

arrayContainer = new Slider.constructArray();

Problem at line 3 character 1: Stopping. (27% scanned).



如何满足JSLint的要求?什么是只读。意味着?


How do I satisfy JSLint's requirements? What does "Read only." mean?

推荐答案

试试这个:

 /*global arrayContainer:true, SliderInstance:true, DomObjects:true, document, Slider*/

通知JSLint故意分配这些全局变量。

Informs JSLint that these globals are assigned intentionally.

这篇关于JavaScript:JSLint抛出“只读”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆