效果图:
项目结构:
注意点:
1.在index中:
配置适应手机
2.assets下面写的通用的css
basic.scss
在main.js中引入
import ‘./assets/css/basic.scss’;
3.使用路由
vue-router
4.请求数据
vue-resource
介绍:
basic.scss全局通用的css,在main.js中引入
index.html是配置html的
main.js是配置文件
App.vue是入口文件
Home.vue是新闻列表
HomeContent.vue是新闻详情
源码:
basic.scss
@charset "utf-8";
body, div, ul, li, ol, h1, h2, h3, h4, h5, h6, input, textarea, select, p, dl, dt, dd, a, img, button, form, table, th, tr, td, tbody, article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section {
margin: 0;
padding: 0;
}
html{
font-size: 62.5%;
}
body {
font: 12px/1.5 'Microsoft YaHei','宋体', Tahoma, Arial, sans-serif;
color: #555;
background-color: #F7F7F7;
}
em, i {
font-style: normal;
}
ul,li{
list-style-type: none;
}
strong {
font-weight: normal;
}
.clearfix:after {
content: "";
display: block;
visibility: hidden;
height: 0;
clear: both;
}
index.html
vuedemo19
main.js
import Vue from 'vue';
import App from './App.vue';
//引入公共的scss 注意:创建项目的时候必须用scss
import './assets/css/basic.scss';
//引用数据请求框架 vue-resource
import VueResource from 'vue-resource';
Vue.use(VueResource);
//引入路由
import VueRouter from 'vue-router';
Vue.use(VueRouter);
import Home from './components/Home.vue';
import HomeContent from './components/HomeContent.vue';
const routes = [
{ path: '/home', component: Home },
{ path: '/homecontent/:aid', component: HomeContent },
{ path: '*', redirect: '/home' } /*默认跳转路由*/
]
const router = new VueRouter({
routes // (缩写)相当于 routes: routes
})
new Vue({
el: '#app',
router,
render: h => h(App)
})
App.vue
Home.vue
列表页
-
{{item.title}}
HomeContent.vue
{{list.title}}
源码下载:
vuedemo19
https://download.csdn.net/download/zhaihaohao1/11112029