Skip to content

Commit

Permalink
Merge pull request #14 from studygolang/isColt
Browse files Browse the repository at this point in the history
fix #13, 增加主页内容页面
  • Loading branch information
deancn authored Mar 11, 2020
2 parents 6e24427 + 10393d5 commit 9083c2a
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 5 deletions.
3 changes: 3 additions & 0 deletions build/miniprogram.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ module.exports = {
doc: [
'/doc/index',
],
article: [
'/article/:id',
],
},
redirect: {
notFound: 'home',
Expand Down
1 change: 1 addition & 0 deletions build/webpack.mp.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module.exports = {
other: path.resolve(__dirname, '../src/mp/other/main.mp.js'),
me: path.resolve(__dirname, '../src/mp/me/main.mp.js'),
doc: path.resolve(__dirname, '../src/mp/doc/main.mp.js'),
article: path.resolve(__dirname, '../src/mp/article/main.mp.js'),
},
output: {
path: path.resolve(__dirname, '../dist/mp/common'), // 放到小程序代码目录中的 common 目录下
Expand Down
18 changes: 18 additions & 0 deletions src/article/Index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<template>
<div class="cnt">
<div>
首页文章内容页 id = {{this.$route.params.id}} <br>
</div>
</div>
</template>

<script>
import Vue from 'vue'
export default Vue.extend({
name: 'Article',
})
</script>
<style lang="less">
</style>
15 changes: 12 additions & 3 deletions src/component/ListContent.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<template>
<div class="listContent">
<div v-for="(item, index) in list" :key="index" class="article_list">
<div
v-for="(item, index) in list"
:key="index"
class="article_list"
@click="jumpToDetail('/article/' + item.id)">
<div class="article_list_item">
<div class="article_detail">
<div>
Expand All @@ -18,8 +22,8 @@
<img :src="item.cover" alt="">
</div>
<div class="article_other">
<div class="acticle_goods">
{{item.goods}}
<div class="like">
{{item.like}}
</div>
<div class="acticle_comments">
{{item.comments}}
Expand All @@ -42,6 +46,11 @@ export default Vue.extend({
return {
}
},
methods: {
jumpToDetail(url) {
window.location.href = url
},
},
props: ['list'],
})
Expand Down
4 changes: 2 additions & 2 deletions src/home/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default Vue.extend({
title: '测试文章1的标题',
description: '测试文章1的描述',
cover: 'https://wechat-1251018873.file.myqcloud.com/images/banner.png',
goods: 6,
like: 6,
comments: 6,
}, {
id: 2,
Expand All @@ -74,7 +74,7 @@ export default Vue.extend({
title: '测试文章2的标题',
description: '测试文章2的描述',
cover: 'https://wechat-1251018873.file.myqcloud.com/images/banner.png',
goods: 16,
like: 16,
comments: 26,
}]
}
Expand Down
34 changes: 34 additions & 0 deletions src/mp/article/main.mp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import Vue from 'vue'
import Router from 'vue-router'
import { sync } from 'vuex-router-sync'
import App from '../../App.vue'
import store from '../../store'
import Article from '../../article/Index.vue'

Vue.use(Router)

const router = new Router({
mode: 'history',
routes: [{
path: '/article/:id',
name: 'Article',
component: Article,
}],
})

export default function createApp() {
const container = document.createElement('div')
container.id = 'app'
document.body.appendChild(container)

Vue.config.productionTip = false

sync(store, router)

return new Vue({
el: '#app',
router,
store,
render: h => h(App)
})
}
5 changes: 5 additions & 0 deletions src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const Home = () => import(/* webpackChunkName: "Home" */'@/home/Index.vue')
const List = () => import(/* webpackChunkName: "List" */'@/list/Index.vue')
const Detail = () => import(/* webpackChunkName: "Detail" */'@/detail/Index.vue')
const Doc = () => import(/* webpackChunkName: "Doc" */'@/doc/Index.vue')
const Article = () => import(/* webpackChunkName: "Article" */'@/article/Index.vue')
Vue.use(Router)

export default new Router({
Expand Down Expand Up @@ -33,5 +34,9 @@ export default new Router({
path: '/doc/index',
name: 'Doc',
component: Doc,
}, {
path: '/article/:id',
name: 'Article',
component: Article,
}],
})

0 comments on commit 9083c2a

Please sign in to comment.