amis2/examples/index.jsx

25 lines
684 B
React
Raw Normal View History

2019-04-30 11:11:25 +08:00
/**
* @file entry of this example.
* @author liaoxuezhi@cloud.com
*/
import './polyfills/index';
2019-06-11 17:00:02 +08:00
import React from 'react';
2019-11-07 10:41:14 +08:00
import {render} from 'react-dom';
2019-04-30 11:11:25 +08:00
import App from './components/App';
export function bootstrap(mountTo, initalState) {
render(<App />, mountTo, () => {
// 由于延迟加载导致初始锚点经常不正确
// 延迟再设置一下锚点,这个问题暂时没想到其它方法
setTimeout(() => {
if (location.hash) {
const hash = location.hash.split('#')[1];
const anchor = document.querySelector(`a[name="${hash}"]`);
if (anchor) {
anchor.scrollIntoView();
}
}
}, 2000);
});
2019-04-30 11:11:25 +08:00
}