windows下vue-cli及webpack 构建网站(一)环境安装
windows下vue-cli及webpack 构建网站(二)导入bootstrap样式
windows下vue-cli及webpack 构建网站(三)使用组件
1、本篇文章是建立在以上三篇文章的基础上的。
2、安装 vue-router 插件,运行cmd进入到项目目录下面,运行以下命令:
cnpm install vue-router --save-dev
3、在src文件夹下面新建一个文件夹page用于存放模板文件,然后分别在这个文件夹下面新建 index.vue、list.vue两个文件,然后打开index.vue粘贴以下代码:
<template> <div class="jumbotron"> <h1>这里是首页!</h1> </div> </template>
保存之后再打开list.vue粘贴以下代码:
<template> <div class="list-group"> <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="list-group-item active"> 这里是列表页 </a> <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="list-group-item">Dapibus ac facilisis in</a> <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="list-group-item">Morbi leo risus</a> <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="list-group-item">Porta ac consectetur ac</a> <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="list-group-item">Vestibulum at eros</a> </div> </template>
好了,两个页面的内容都准备好了,接下来我们修改入口文件app.vue的内容吧
4、打开src文件夹下面的app.vue文件,修改代码为
<template> <div> <HtmlHeader></HtmlHeader> <router-view class="view" keep-alive transition transition-mode="out-in"> </router-view> <HtmlFooter></HtmlFooter><span style="white-space:pre"> </span> </div> <span style="white-space:pre"> </span> </template> <script> import HtmlHeader from './components/header' import HtmlFooter from './components/footer' export default { components: { HtmlHeader, HtmlFooter } } </script>
这里用了 router-view 来把刚才新建的两个页面加载到这里来
修改了入口文件接下来就是要进行路由规则的配置了。
5、在src文件夹下面新建一个文件夹config用来存放路由配置,在config文件夹下面新建routes.js文件并打开,然后粘贴以下代码并保存:
//加载模板文件 import index from '../page/index' import list from '../page/list' //路由规则设置 export default [ { path: '/', component: index }, { path: '/list', component: list } ]
现在路由配置文件也已经配置好了,我们接下来就是要打开sec文件夹下面的main.js文件设置路由使用了
6、打开main.js 文件,在头部加入以下代码
// 引用路由插件 import VueRouter from 'vue-router' // 试用路由插件 Vue.use(VueRouter) //引入路由配置文件 import routes from './config/routes' // 使用配置文件规则 const router = new VueRouter({ mode: 'history', base: __dirname, routes: routes })
这个是引入路由插件并且使用,然后加载路由规则
接着把
new Vue({ el: '#app', template: '<App/>', components: { App } })
修改为
const app = new Vue({ router: router, render: h => h(App) }).$mount('#app')
设置完之后整个页面代码如图
7、加载开始运行 npm run dev 查看效果吧,打开http://localhost:8080 和http://localhost:8080/list 就可以看到不同的效果了
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
《魔兽世界》大逃杀!60人新游玩模式《强袭风暴》3月21日上线
暴雪近日发布了《魔兽世界》10.2.6 更新内容,新游玩模式《强袭风暴》即将于3月21 日在亚服上线,届时玩家将前往阿拉希高地展开一场 60 人大逃杀对战。
艾泽拉斯的冒险者已经征服了艾泽拉斯的大地及遥远的彼岸。他们在对抗世界上最致命的敌人时展现出过人的手腕,并且成功阻止终结宇宙等级的威胁。当他们在为即将于《魔兽世界》资料片《地心之战》中来袭的萨拉塔斯势力做战斗准备时,他们还需要在熟悉的阿拉希高地面对一个全新的敌人──那就是彼此。在《巨龙崛起》10.2.6 更新的《强袭风暴》中,玩家将会进入一个全新的海盗主题大逃杀式限时活动,其中包含极高的风险和史诗级的奖励。
《强袭风暴》不是普通的战场,作为一个独立于主游戏之外的活动,玩家可以用大逃杀的风格来体验《魔兽世界》,不分职业、不分装备(除了你在赛局中捡到的),光是技巧和战略的强弱之分就能决定出谁才是能坚持到最后的赢家。本次活动将会开放单人和双人模式,玩家在加入海盗主题的预赛大厅区域前,可以从强袭风暴角色画面新增好友。游玩游戏将可以累计名望轨迹,《巨龙崛起》和《魔兽世界:巫妖王之怒 经典版》的玩家都可以获得奖励。
更新日志
- 《小朋友齐打交》真人电影预告公开 预计明年推出
- 《萨顶顶-华人首位获格莱美奖提名 怜香伴》[WAV/分轨][420MB]
- 《极致真发烧·HIFI过耳不忘 3CD》[WAV/分轨][1.8GB]
- 《流行HIFI摇滚音乐 摇滚在发烧 2CD》[WAV/分轨][1.3GB]
- 没有才能.2024-我终于也变成人了【华研国际】【FLAC分轨】
- 张国荣.1995-宠爱(2014年K2HD限量版)【滚石】【WAV+CUE】
- 林姗.2009-个人精选集【芮河】【WAV+CUE】
- 魔兽世界地心之战织雾武僧用什么饰品 地心之战织雾武僧饰品推荐
- 瑞鸣《喜马拉雅》[WAV+CUE]
- 【古典音乐】郑京和《华纳录音全集》11CD.2015[FLAC+CUE]
- 群星《经典再现·国语男声》2CD[DTS-WAV]
- 打完猴了!来聊聊你最喜欢哪段故事!
- 玩家分享《黑神话:悟空》大怨种:想痛快玩游戏花了快400块
- 作者回应《黑神话》墙绘被毁:当地相关部门支持重绘
- 李泉.1995-上海梦【魔岩】【WAV+CUE】