
本文共 2283 字,大约阅读时间需要 7 分钟。
������������������������������������������������������������������������������������������������
���������������������������������
������������������������������������������������������������ Web ������������������������������������������������������������������������������������������������������������������������������������������������������������������ Vue.js ��������������������������� Vue ������������������������������������������������������������������������
������������
���������������������������������������������
������������������
npm install history
- ������ Vue ������������������ Vue ������������������������
- ���������������������������������������������������������������������������
- ��������������������� Vue ������������������������������������
- ������������������������������ hashchange ������������������������������
- ������������ ������ hash ���������������������������������������������������������
- ������������ ��� URL ������������������������������������������������������
- ������������ ���������������������������������������������������������������������������������
const vm = new Vue({ el: '#app', History: History})
// home ������������const home = { template: '������������'}// tech ������������const tech = { template: '������������'}
const routes = { '/': home, '/tech': tech, // ������������������}
window.addEventListener('hashchange', () => { // ������������ URL ������������������ const currentPath = window.location.pathname const routeComponent = routes[currentPath.replace('/','')] vm.currentComponent = routeComponent})
������������
���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
发表评论
最新留言
关于作者
