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);
if (text.lastIndexOf('?') !== -1)
text = text.substr(0, text.lastIndexOf('?')); // fuck wechat '#param?nsukey=...'
if (text === '##') return;
this.setState(
{
search_text: text,
},
() => {
this.on_keypress({ key: 'Enter' });
},
);
if (text !== '#' && text !== '##') {
this.setState(
{
search_text: text,
},
() => {
this.on_keypress({ key: 'Enter' });
},
);
}
}
console.log('add change lis');
window.addEventListener(
'hashchange',
() => {

Loading…
Cancel
Save