Uncaught TypeError:无法读取jQuery中未定义的属性“ split”

我正在使用input字段包括日期选择器。如果我单独运行,则日期选择器的代码可以完美运行。但是,当我集成datepicker input字段时,出现错误:

  

未捕获的TypeError:无法读取未定义的属性“ split”

我还包括了必需的CSS和脚本的所有必需的库和链接。

<div id="select" class="inner">
  <select id="test-options">
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    <option value="date">Select date time</option>
  </select>
</div>
<div id="datepicker" class="inner">
  <p>Date: <input type="text" id="datepicker-input"></p>
</div>
$(function() {
  $('#test-options').change(function() {
    if ($(this).val() === 'date') {
      var $datepicker = $("#datepicker-input");
      $datepicker.datepicker({
        beforeShow: function(input,inst) {
          $(input).datepicker('setDate',new Date());
        }
      });
      $datepicker.datepicker("show");
    }
  });
});
if ($(this).attr('type'))
  input['type'] = $(this).attr('type');

// this is what causes the error:
input['questions'] = $(this).attr('data-conv-question').split("|");
ysw9232 回答:Uncaught TypeError:无法读取jQuery中未定义的属性“ split”

原因是,您正在寻找输入的事实,但没有输入

inputStream.apply(ParDo.of(new DoFn<String,KV<String,String>>() { @ProcessElement public void processElement(ProcessContext c) { c.output(KV.of("",c.element())); } })).apply(ParDo.of(new DoFn<KV<String,String>,String>() { @StateId("stateRetention") private final StateSpec<ValueState<Map<String,String>>> state = StateSpecs .value(MapCoder.of(StringUtf8Coder.of(),StringUtf8Coder.of())); Map<String,String> map = new HashMap<>(); private final Duration MAX_BUFFER_DURATION = Duration.standardSeconds(20); @TimerId("TimerRetention") private final TimerSpec timer = TimerSpecs.timer(TimeDomain.PROCESSING_TIME); @ProcessElement public void processElement(ProcessContext c,@StateId("stateRetention") ValueState<Map<String,String>> state,@TimerId("TimerRetention") Timer timer,BoundedWindow window) { timer.offset(MAX_BUFFER_DURATION).setRelative(); Map<String,String> localStateMap = (state.read() != null) ? state.read() : new HashMap<>(); String record = c.element().getValue(); String id = record.split("@@")[0]; String value = record.split("@@")[1]; String valueFromState = localStateMap.get(id); map.put(id,valueFromState + " " + value + " "); state.write(map); System.out.println(localStateMap.get(id)); c.output(record); } @OnTimer("TimerRetention") public void onMyTimer(OnTimerContext otc,String>> state) { state.clear(); } })); questions 是span元素的文本 data-conv-question

看看固定的示例,尽管没有产生问题的结果,但仍然可以正常工作:

Working js fiddle

可以随意使用它,但请确保您指向的是代码中正确的元素。

本文链接:https://www.f2er.com/2901060.html

大家都在问