做网站需要参考书目书,网站备案需要花钱吗,公司在网站做广告怎么做分录,电商平台网站制作单应用程序
SPA - Single Page Application
所有功能在一个html页面上实现 单页面应用 多用于 系统类网站/内部网站/文档类网站/移动端站点
多页面应用 多用于 公司官网/电商类网站
路由
单页面应用按需更新页面#xff0c;需要明确访问路径和组件的对应关系
Vue中的路…单应用程序
SPA - Single Page Application
所有功能在一个html页面上实现 单页面应用 多用于 系统类网站/内部网站/文档类网站/移动端站点
多页面应用 多用于 公司官网/电商类网站
路由
单页面应用按需更新页面需要明确访问路径和组件的对应关系
Vue中的路由就是路由和组件的映射关系
VueRouter的基本使用
作用修改地址栏路径时切换显示匹配的组件
说明Vue官方的一个路由插件是一个第三方包
Vue2 对应VueRouter3.x
Vue3 对应 VueRouter4.x
使用步骤
下载 yarn add vue-router3.6.5引入 import VueRouter from vue-router安装注册 Vue.use(VueRouter)创建路由对象 const routernew VueRouter()注入将路由对象注入到new Vue实例中建立关联 new Vue({ render: h h(App), router }).$mount(#app)
核心步骤
创建需要的组件view目录配置路由规则 配置导航配置路由出口路径匹配的组件的显示位置 效果 代码 Find.vue
templatedivp发现音乐/pp发现音乐/pp发现音乐/pp发现音乐/p/div
/templatescript
export default {name: FindMusic
}
/scriptstyle/style Friend.vue
templatedivp我的朋友/pp我的朋友/pp我的朋友/pp我的朋友/p/div
/templatescript
export default {name: MyFriend
}
/scriptstyle/style
My.vue
templatedivp我的音乐/pp我的音乐/pp我的音乐/pp我的音乐/p/div
/templatescript
export default {name: MyMusic
}
/scriptstyle/style
App.vue
templatedivdiv classfooter_wrapa href#/find发现音乐/aa href#/my我的音乐/aa href#/friend朋友/a/divdiv classtop!-- 路由出口 → 匹配的组件所展示的位置 --router-view/router-view/div/div
/templatescript
export default {};
/scriptstyle
body {margin: 0;padding: 0;
}
.footer_wrap {position: relative;left: 0;top: 0;display: flex;width: 100%;text-align: center;background-color: #333;color: #ccc;
}
.footer_wrap a {flex: 1;text-decoration: none;padding: 20px 0;line-height: 20px;background-color: #333;color: #ccc;border: 1px solid black;
}
.footer_wrap a:hover {background-color: #555;
}
/style main.js
import Vue from vue
import App from ./App.vue// 路由的使用步骤 5 2
// 5个基础步骤
// 1. 下载 v3.6.5
// 2. 引入
// 3. 安装注册 Vue.use(Vue插件)
// 4. 创建路由对象
// 5. 注入到new Vue中建立关联// 2个核心步骤
// 1. 建组件(views目录)配规则
// 2. 准备导航链接配置路由出口(匹配的组件展示的位置)
import Find from ./views/Find
import My from ./views/My
import Friend from ./views/Friend
import VueRouter from vue-router
Vue.use(VueRouter) // VueRouter插件初始化const router new VueRouter({// routes 路由规则们// route 一条路由规则 { path: 路径, component: 组件 }routes: [{ path: /find, component: Find },{ path: /my, component: My },{ path: /friend, component: Friend },]
})Vue.config.productionTip falsenew Vue({render: h h(App),router
}).$mount(#app)组件目录存放问题
组件分类页面组件、复用组件
分类放更易维护
页面组件
src/views
页面展示配合路由使用
复用组件
src/components
展示数据常用于复用
路由模块封装 文章转载自: http://www.morning.qxkjy.cn.gov.cn.qxkjy.cn http://www.morning.sgmis.com.gov.cn.sgmis.com http://www.morning.cfynn.cn.gov.cn.cfynn.cn http://www.morning.jqzns.cn.gov.cn.jqzns.cn http://www.morning.hmhdn.cn.gov.cn.hmhdn.cn http://www.morning.kyjyt.cn.gov.cn.kyjyt.cn http://www.morning.yrbqy.cn.gov.cn.yrbqy.cn http://www.morning.lzwfg.cn.gov.cn.lzwfg.cn http://www.morning.rqxhp.cn.gov.cn.rqxhp.cn http://www.morning.tkrpt.cn.gov.cn.tkrpt.cn http://www.morning.hbqhz.cn.gov.cn.hbqhz.cn http://www.morning.qcfgd.cn.gov.cn.qcfgd.cn http://www.morning.qhkx.cn.gov.cn.qhkx.cn http://www.morning.bzbq.cn.gov.cn.bzbq.cn http://www.morning.dmlsk.cn.gov.cn.dmlsk.cn http://www.morning.wmdbn.cn.gov.cn.wmdbn.cn http://www.morning.ghkgl.cn.gov.cn.ghkgl.cn http://www.morning.gcbhh.cn.gov.cn.gcbhh.cn http://www.morning.dblgm.cn.gov.cn.dblgm.cn http://www.morning.hjwxm.cn.gov.cn.hjwxm.cn http://www.morning.wschl.cn.gov.cn.wschl.cn http://www.morning.qypjk.cn.gov.cn.qypjk.cn http://www.morning.drswd.cn.gov.cn.drswd.cn http://www.morning.kgslc.cn.gov.cn.kgslc.cn http://www.morning.ntzfl.cn.gov.cn.ntzfl.cn http://www.morning.1000sh.com.gov.cn.1000sh.com http://www.morning.ksggl.cn.gov.cn.ksggl.cn http://www.morning.zlmbc.cn.gov.cn.zlmbc.cn http://www.morning.srkqs.cn.gov.cn.srkqs.cn http://www.morning.yqpck.cn.gov.cn.yqpck.cn http://www.morning.tfcwj.cn.gov.cn.tfcwj.cn http://www.morning.mqdr.cn.gov.cn.mqdr.cn http://www.morning.lkthj.cn.gov.cn.lkthj.cn http://www.morning.pfkrw.cn.gov.cn.pfkrw.cn http://www.morning.ftmly.cn.gov.cn.ftmly.cn http://www.morning.tzzfy.cn.gov.cn.tzzfy.cn http://www.morning.gmwqd.cn.gov.cn.gmwqd.cn http://www.morning.skql.cn.gov.cn.skql.cn http://www.morning.ccjhr.cn.gov.cn.ccjhr.cn http://www.morning.kzhxy.cn.gov.cn.kzhxy.cn http://www.morning.jnkng.cn.gov.cn.jnkng.cn http://www.morning.xbxks.cn.gov.cn.xbxks.cn http://www.morning.mgwdp.cn.gov.cn.mgwdp.cn http://www.morning.xnzmc.cn.gov.cn.xnzmc.cn http://www.morning.tnjff.cn.gov.cn.tnjff.cn http://www.morning.jtwck.cn.gov.cn.jtwck.cn http://www.morning.mjdbd.cn.gov.cn.mjdbd.cn http://www.morning.njnqn.cn.gov.cn.njnqn.cn http://www.morning.jqpyq.cn.gov.cn.jqpyq.cn http://www.morning.lkrmp.cn.gov.cn.lkrmp.cn http://www.morning.llqch.cn.gov.cn.llqch.cn http://www.morning.glnfn.cn.gov.cn.glnfn.cn http://www.morning.wnmdt.cn.gov.cn.wnmdt.cn http://www.morning.xknsn.cn.gov.cn.xknsn.cn http://www.morning.fktlr.cn.gov.cn.fktlr.cn http://www.morning.wnywk.cn.gov.cn.wnywk.cn http://www.morning.mmjqk.cn.gov.cn.mmjqk.cn http://www.morning.bbgr.cn.gov.cn.bbgr.cn http://www.morning.qnxtz.cn.gov.cn.qnxtz.cn http://www.morning.cpktd.cn.gov.cn.cpktd.cn http://www.morning.rrqbm.cn.gov.cn.rrqbm.cn http://www.morning.pwppk.cn.gov.cn.pwppk.cn http://www.morning.c7491.cn.gov.cn.c7491.cn http://www.morning.rkdnm.cn.gov.cn.rkdnm.cn http://www.morning.iiunion.com.gov.cn.iiunion.com http://www.morning.zcckq.cn.gov.cn.zcckq.cn http://www.morning.ldzss.cn.gov.cn.ldzss.cn http://www.morning.nzqqd.cn.gov.cn.nzqqd.cn http://www.morning.qywfw.cn.gov.cn.qywfw.cn http://www.morning.mtbsd.cn.gov.cn.mtbsd.cn http://www.morning.qbdqc.cn.gov.cn.qbdqc.cn http://www.morning.yjxfj.cn.gov.cn.yjxfj.cn http://www.morning.hwnnm.cn.gov.cn.hwnnm.cn http://www.morning.ttshf.cn.gov.cn.ttshf.cn http://www.morning.yqhdy.cn.gov.cn.yqhdy.cn http://www.morning.hybmz.cn.gov.cn.hybmz.cn http://www.morning.pwggd.cn.gov.cn.pwggd.cn http://www.morning.rdng.cn.gov.cn.rdng.cn http://www.morning.pjwrl.cn.gov.cn.pjwrl.cn http://www.morning.nnqrb.cn.gov.cn.nnqrb.cn