2
Phpstorm不断告诉我,我有一个未定义的变量input.connectto
Jshint/PhpStorm: “未解决的变量” 使用jQuery的.data()时
HTML: <div class="b-showColorinList" data-connectto="123456" data-othervalue="Lorem Ipsum">...
JS:
$(document).on('click', '.b-showColorinList', function() {
cm.showColorInList($(this));
});
而且:
/**
* Uses ajax to get other color in list view
* @param {object} inputObj
*/
cm.showColorInList = function(inputObj) {
"use strict";
var input = inputObj.data(),
parent = $("#"+input.connectto),
othervalue = input.othervalue;
我知道我可以忽略在一个jshint线,但有任何方法,使之与jsdoc正确,例如限定input
作为对象
如果您使用jQuery(如在$('.b-showColorinList')。data('connectto');')中,为什么不使用data(“connectto”)? – LazyOne
对不起,我缩短了一下代码。当一个数据字段实际上更多。修正了现在 – Krillko
我明白 - 我只是在想 - 如果这不是任务关键的代码或者执行得非常频繁或者需要立即执行而没有延迟的事情......那么为什么不用'data'方法来调用具体参数。 – LazyOne