模仿豆瓣前端 - douban

2015-09-08      400      Vue
项目简介

模仿豆瓣前端

Use Vue.js 2.0,

vue.js 2.0, vuex, vue-router, vue-server-renderer, express, cheerio, superagent, redis

Build

#redis-server

redis-server &

# install dependencies
npm install

# serve with hot reload at localhost:8080
npm run dev

# build for production with minification
npm run build && npm start

注意

  1. 请确认redis是start状态
  2. 在浏览器中访问 http://127.0.0.1:8080/api/spider 启动爬虫
  3. 目前完成的界面: 首页, 读书首页, 标签页, 列表页, 详情页

    http://127.0.0.1:8080/

    http://127.0.0.1:8080/book

    http://127.0.0.1:8080/tags

    http://127.0.0.1:8080/tag/javascript

    http://127.0.0.1:8080/subject/3332698

更新到 vue.js2.0 记录

  1. 在2.0中Vue.set(store.item, item)不会触发更新dom,store.item = item才可以
  2. 由于server side render的原因, 不能使用vue-resource了, 改用superagent发请求了
  3. store.item为{}时, 在页面中引用 会直接error, mock数据, 请求成功再更新
  4. webpack出现了 mdzz 的错误Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.解决办法为:
npm uninstall webpack --save-dev

followed by

npm install webpack@2.1.0-beta.22 --save-dev

Then you should be able to gulp again. Fixed the issue for me.

然后npm run dev即可

<div>
  <span v-for="n in 10">{{ n }}</span> // 需要指定n
</div>
<div>
  <span v-for="(item, $index) in items">{{ $index }}</span> // 需要显示声明$index
</div>
  1. 上面的 bug 已经被 尤大 fixed

目录结构

.
├── README.md 
├── build
├── index.html
├── server.js
├── fe
│   ├── App.vue
│   ├── app.js
│   ├── assets
│   ├── client-entry.js
│   ├── components
│   ├── router
│   ├── server-entry.js
│   ├── store
│   └── views
├── be
│   ├── spiders
│   └── routers
├── node_modules
├── package.json
├── public
└── test