Vuejs-Node vue server webpack: Vue Cookbook (Vue1.0 + express) @yjj5855Vue Cookbook (Vue1.0 + express) by @yjj5855: A demo first screen rendering of a service

使用node.js+Vue.js+webpack

用node当前端服务器和后台服务器通讯和渲染页面,使用vue,vue-server,vue-router来实现SPA应用.

解决了SPA应用的SEO缺点,访问的第一个页面,使用vue-server来服务端渲染.使用vue-router+webpack实现APP模块懒加载

这只是一个快速开发框架.

一个简单的demo

1.安装

npm install

2.typescript依赖安装 (需全局安装tsd)

tsd install

3.编译ts文件 (需全局安装tsc)

tsc

4.启动服务

node server 或 npm run dev

版本 V0.2.0

  • 删除多余文件
  • 服务端使用 async函数 获取API数据
  • babel 升级(5升6)

版本 V0.1.1

  • 增加env文件

版本 V0.1.0

  • 分环境webpack打包
  • 新增模块化css打包
  • 新增车型选择功能
  • 新增城市选择功能

版本 V0.0.8

  • 去除侧边栏 为单独一页
  • 新增 搜索页面
  • 新增 sui-picker指令

版本 V0.0.7

  • 去掉vue-resource使用zepto的ajax (兼容性原因)

版本 V0.0.6

  • 分离service层
  • 兼容微信浏览器中Promise.all保错 引入Q.js

版本 V0.0.5

新增侧边栏,登陆页面,localStorage缓存

版本 V0.0.4

仿网易新闻操作方式(安卓微信中有少许BUG)

Comments

  • tsc编译报错
    tsc编译报错

    Feb 26, 2016

    你好,我试了下运行这个应用,tsc进行编译就报错了,如下 server.ts(1,23): error TS2307: Cannot find module 'http'. server.ts(2,22): error TS2307: Cannot find module 'url'. server.ts(3,26): error TS2307: Cannot find module 'express'. server.ts(4,29): error TS2307: Cannot find module 'body-parser'. server.ts(5,31): error TS2307: Cannot find module 'errorhandler'. server.ts(6,33): error TS2307: Cannot find module 'method-override'. server.ts(7,31): error TS2307: Cannot find module 'cookie-parser'. server.ts(8,22): error TS2307: Cannot find module './env'. server.ts(25,19): error TS2304: Cannot find name 'require'. server.ts(26,32): error TS2304: Cannot find name 'require'. server.ts(27,25): error TS2304: Cannot find name 'require'. server.ts(35,21): error TS2304: Cannot find name '__dirname'. server.ts(41,21): error TS2304: Cannot find name 'require'. server.ts(47,24): error TS2304: Cannot find name '__dirname'. server/routes/chat.ts(2,26): error TS2307: Cannot find module 'express'. server/routes/chat.ts(3,28): error TS2307: Cannot find module 'vue-server'. server/routes/chat.ts(4,21): error TS2307: Cannot find module 'fs'. server/routes/chat.ts(5,26): error TS2307: Cannot find module 'request'. server/routes/chat.ts(6,30): error TS2307: Cannot find module 'querystring'. server/routes/chat.ts(7,22): error TS2307: Cannot find module '../../env'. server/routes/cookbook.ts(2,26): error TS2307: Cannot find module 'express'. server/routes/cookbook.ts(3,28): error TS2307: Cannot find module 'vue-server'. server/routes/cookbook.ts(4,21): error TS2307: Cannot find module 'fs'. server/routes/cookbook.ts(5,26): error TS2307: Cannot find module 'request'. server/routes/cookbook.ts(6,30): error TS2307: Cannot find module 'querystring'. server/routes/cookbook.ts(7,22): error TS2307: Cannot find module '../../env'. server/routes/cookbook.ts(10,16): error TS2304: Cannot find name 'require'. server/routes/cookbook.ts(60,42): error TS2339: Property 'tngou' does not exist on type 'Object'. server/routes/cookbook.ts(63,38): error TS2339: Property 'total' does not exist on type 'Object'. server/routes/cookbook.ts(76,59): error TS2339: Property 'tngou' does not exist on type 'Object'. server/routes/cookbook.ts(79,40): error TS2339: Property 'total' does not exist on type 'Object'. server/routes/cookbookDetail.ts(2,26): error TS2307: Cannot find module 'express'. server/routes/cookbookDetail.ts(3,28): error TS2307: Cannot find module 'vue-server'. server/routes/cookbookDetail.ts(4,21): error TS2307: Cannot find module 'fs'. server/routes/cookbookDetail.ts(5,26): error TS2307: Cannot find module 'request'. server/routes/cookbookDetail.ts(6,30): error TS2307: Cannot find module 'querystring'. server/routes/cookbookDetail.ts(7,22): error TS2307: Cannot find module '../../env'. server/routes/cookbookDetail.ts(33,27): error TS2339: Property 'img' does not exist on type 'Object'. server/routes/index.ts(2,26): error TS2307: Cannot find module 'express'. server/routes/index.ts(3,28): error TS2307: Cannot find module 'vue-server'. server/routes/index.ts(4,21): error TS2307: Cannot find module 'fs'. server/routes/index.ts(5,26): error TS2307: Cannot find module 'request'. server/routes/index.ts(6,30): error TS2307: Cannot find module 'querystring'. server/routes/index.ts(7,22): error TS2307: Cannot find module '../../env'. server/routes/login.ts(2,26): error TS2307: Cannot find module 'express'. server/routes/login.ts(3,28): error TS2307: Cannot find module 'vue-server'. server/routes/login.ts(4,21): error TS2307: Cannot find module 'fs'. server/routes/login.ts(5,26): error TS2307: Cannot find module 'request'. server/routes/login.ts(6,30): error TS2307: Cannot find module 'querystring'. server/routes/login.ts(7,22): error TS2307: Cannot find module '../../env'. server/routes/member.ts(2,26): error TS2307: Cannot find module 'express'. server/routes/member.ts(3,28): error TS2307: Cannot find module 'vue-server'. server/routes/member.ts(4,21): error TS2307: Cannot find module 'fs'. server/routes/member.ts(5,26): error TS2307: Cannot find module 'request'. server/routes/member.ts(6,30): error TS2307: Cannot find module 'querystring'. server/routes/member.ts(7,22): error TS2307: Cannot find module '../../env'. server/routes/search.ts(2,26): error TS2307: Cannot find module 'express'. server/routes/search.ts(3,28): error TS2307: Cannot find module 'vue-server'. server/routes/search.ts(4,21): error TS2307: Cannot find module 'fs'. server/routes/search.ts(5,26): error TS2307: Cannot find module 'request'. server/routes/search.ts(6,30): error TS2307: Cannot find module 'querystring'. server/routes/search.ts(7,22): error TS2307: Cannot find module '../../env'.

    Reply
  • node启动服务出错
    node启动服务出错

    Apr 29, 2016

    node启动服务出错,具体如下,不应该是代码问题,我按照步骤弄得,是不是缺少了什么? 错误信息如下:

    /projects/routertest/node-vue-server-webpack/server/routes/cookbook.js:11 var classes = await, getCookbookClass_1 = (); ^

    SyntaxError: Expected () to start arrow function, but got ';' instead of '=>' at exports.runInThisContext (vm.js:53:16) at Module._compile (module.js:373:25) at Object.Module._extensions..js (module.js:416:10) at Module.load (module.js:343:32) at Function.Module._load (module.js:300:12) at Module.require (module.js:353:17) at require (internal/module.js:12:17) at Object. (/home/luyi/projects/routertest/node-vue-server-webpack/server.js:9:16) at Module._compile (module.js:409:26) at Object.Module._extensions..js (module.js:416:10)

    Reply
  • 访问提供的地址列表,返回的时候并没有记住history位置
    访问提供的地址列表,返回的时候并没有记住history位置

    Oct 8, 2016

    saveScrollPosition貌似没有记住 eg.: http://182.92.99.230:3000/cookbook/1

    Reply
  • ./env ? where go?
    ./env ? where go?

    Feb 26, 2016

    ./env ? where go?

                                                                                                                                                                                                           
    Reply