Browse Source

fix hashchange listener

master
hole-thu 3 years ago
parent
commit
e2505377cd
  1. 20
      src/Title.js

20
src/Title.js

@ -26,17 +26,19 @@ class ControlBar extends PureComponent {
let text = decodeURIComponent(window.location.hash).substr(1); let text = decodeURIComponent(window.location.hash).substr(1);
if (text.lastIndexOf('?') !== -1) if (text.lastIndexOf('?') !== -1)
text = text.substr(0, text.lastIndexOf('?')); // fuck wechat '#param?nsukey=...' text = text.substr(0, text.lastIndexOf('?')); // fuck wechat '#param?nsukey=...'
if (text === '##') return; if (text !== '#' && text !== '##') {
this.setState( this.setState(
{ {
search_text: text, search_text: text,
}, },
() => { () => {
this.on_keypress({ key: 'Enter' }); this.on_keypress({ key: 'Enter' });
}, },
); );
}
} }
console.log('add change lis');
window.addEventListener( window.addEventListener(
'hashchange', 'hashchange',
() => { () => {

Loading…
Cancel
Save