我不知道javascript。 [英] I dont konw javascript .

查看:121
本文介绍了我不知道javascript。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨我有这样的功能



131 parameterValueList = function(xml){

132 var e,err,j, len,name,ref1,value,valueList,valueType;

133 valueList = [];

134 ref1 = xml.find('ParameterValueStruct');

135 for(j = 0,len = ref1.length; j< len; j ++){

136 e = ref1 [j];

137 valueType = e.get('Value')。attr('type')。value()。trim();

138 name = e.get('Name')。text()。 trim();

139 value = e.get('Value')。text()。trim();

140试试{

141 switch(valueType){

142 case'xsd:boolean':

143 value = Boolean(JSON.parse(value));

144 break;

145 case'xdd:unsignedInt':

146 value = JSON.parse(value);

147 break;

148 case'xsd:int':

149 value = JSON.pars e(值);

150}

151} catch(_error){

152 err = _error;

153 value = null;

154}

155 valueList.push([name,value,valueType]);

156}

157返回valueList;

158};







我的错误是



util.error:改用console.error

2015-07-10T05:10:12.082Z - TypeError:无法读取null的属性'value'

在parameterValueList(/opt/genieacs/lib/soap.js:137:44)

at acsInform(/ opt / genieacs / lib / soap.js:292:20)

at Object.exports.request(/opt/genieacs/lib/soap.js:425:39)

at /opt/genieacs/lib/cwmp.js:638:26
getBession
(/opt/genieacs/lib/cwmp.js:569:12)

at IncomingMessage<匿名> (/opt/genieacs/lib/cwmp.js:636:12)

at IncomingMessage.emit(events.js:104:17)

at _stream_readable.js: 908:16

at process._tickDomainCallback(node.js:381:11)



任何人都可以建议我如何解决这个问题问题。

Hi I have a function like this

131 parameterValueList = function(xml) {
132 var e, err, j, len, name, ref1, value, valueList, valueType;
133 valueList = [];
134 ref1 = xml.find('ParameterValueStruct');
135 for (j = 0, len = ref1.length; j < len; j++) {
136 e = ref1[j];
137 valueType = e.get('Value').attr('type').value().trim();
138 name = e.get('Name').text().trim();
139 value = e.get('Value').text().trim();
140 try {
141 switch (valueType) {
142 case 'xsd:boolean':
143 value = Boolean(JSON.parse(value));
144 break;
145 case 'xsd:unsignedInt':
146 value = JSON.parse(value);
147 break;
148 case 'xsd:int':
149 value = JSON.parse(value);
150 }
151 } catch (_error) {
152 err = _error;
153 value = null;
154 }
155 valueList.push([name, value, valueType]);
156 }
157 return valueList;
158 };



My error is

util.error: Use console.error instead
2015-07-10T05:10:12.082Z - TypeError: Cannot read property 'value' of null
at parameterValueList (/opt/genieacs/lib/soap.js:137:44)
at acsInform (/opt/genieacs/lib/soap.js:292:20)
at Object.exports.request (/opt/genieacs/lib/soap.js:425:39)
at /opt/genieacs/lib/cwmp.js:638:26
at getSession (/opt/genieacs/lib/cwmp.js:569:12)
at IncomingMessage.<anonymous> (/opt/genieacs/lib/cwmp.js:636:12)
at IncomingMessage.emit (events.js:104:17)
at _stream_readable.js:908:16
at process._tickDomainCallback (node.js:381:11)

Can any one please suggest me how to solve this issue.

推荐答案

如果您不了解Javascript,那么您不应该使用它!



所以从Javascript教程开始 - Google [ ^ ]有加载。

这里是一: http://www.w3schools.com/js/ [ ^ ]



在尝试进行任何工作之前学习语言。只需从互联网上随机抓取代码并将其固定到您的网站上就不是一个好主意......您需要了解它是如何工作的,这也意味着理解该语言。
If you don't know Javascript, then you shouldn't be using it!

So start with a Javascript tutorial - Google[^] has loads.
Here's one: http://www.w3schools.com/js/[^]

And learn the language before you try to do any work in it. Just grabbing code at random from the internet and bolting it into your website is not a good idea...you need to understand how it works and that means understanding the language as well.


这篇关于我不知道javascript。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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