我构建包装器:
包装器无法找到此元素。控制台日志输出如下:
所以正确id的输入框肯定在那里。我是不是漏掉了什么?
this.wrapper = mount(<App />, { context: this.store });
然后我尝试根据其id查找特定的HTML元素:
console.log("WRAPPER:", this.wrapper.debug());
return this.wrapper.find('#Form-input[0]-fields-field1');
包装器无法找到此元素。控制台日志输出如下:
WRAPPER:
<Many children/components down...>
<input name="Form-input[0].fields.field1" onBlur={[Function]} onChange={[Function]} onDragStart={[Function]} onDrop={[Function]} onFocus={[Function]} value="asdf" type="text" id="Form-input[0]-fields-field1" disabled={false} />
<Many more things after this...>
所以正确id的输入框肯定在那里。我是不是漏掉了什么?
find
函数的参数不像普通的CSS选择器字符串一样被处理,这点非常令人困惑!它似乎在寻找]
字符时会忽略该字符后面的所有内容。 - Infamous911