认真学习前端第一天
1.不用下载router的语法:定义一个路由变量,定义currentPath(响应式的变量),currentview;(这一步没看懂)
1 const currentPath = ref(window.location.hash)
2 window.addEventListener('hashchange', () => {
3 currentPath.value = window.location.hash
4 })
5 const currentView = computed(() => {
6 return routes[currentPath.value.slice(1) || '/'] || NotFound
7 })
->写链接(链接对应#+上面的变量)+组件component:is
2.要下载的路由语法:创建项目的时候记得勾选路由,在router文件夹里的index.js写path和component(即路由的配置),应用的地方<router-view />
3.学习方向:webpack,vue-cli,router-link,路由配置里name的作用,created()和mouted()放在哪里,二级路由children,监听的用法
总结:今天学了一个半小时左右,在routerview花太多时间了,在原文件不显示,新建了一个又显示了,啊啊啊搞不明白
浙公网安备 33010602011771号