export default {
namespace: 'test',
state: {
result: ''
},
reducers: {
setResult(state, result) {
return {...state, result};
}
},
effects: {},
subscriptions: {
set({dispatch}) {
document.addEventListener('onkeypress', e => console.log(e))
let key = '';
document.onkeypress = e => {
if(e.keyCode === 13) {
console.log(key);
window.open(`http://www.baidu.com?key=${key}`)
key = '';
} else {
key += e.key;
}
}
}
}
}
转载于:https://my.oschina.net/xuqiang/blog/954868