解决方法,见如下代码:

原例:

1
2
3
4
5
6
7
8
9
10
11
12
let input = someInput; 
let lastValue = input.value;
input.value = 'new value';
let event = new Event('input', { bubbles: true });
// hack React15
event.simulated = true;
// hack React16 内部定义了descriptor拦截value,此处重置状态
let tracker = input._valueTracker;
if (tracker) {
tracker.setValue(lastValue);
}
input.dispatchEvent(event);

js操作示例:

1
2
3
4
5
6
7
8
var test = document.querySelectorAll("input.m-addr-input ")[0];
test.value = "蒋毅"
var event = new Event('input', {bubbles: true});
var tracker = test._valueTracker;
if(tracker){
tracker.setValue('');
}
test.dispatchEvent(event);

原始资料地址