爱意满满的作品展示区。
sox

Vue 服务器端渲染从未这么简单

  •  
  •   sox ·
    egoist · Mar 20, 2017 · 7390 views
    This topic created in 3526 days ago, the information mentioned may be changed or developed.

    unvue 是基于 vue-router 的 Vue.js 应用同构 (SSR) 渲染框架, Vue 2.2 和最新的 vue-server-renderer 已经让 SSR 十分简单了,更进一步就是减少 boilerplate 代码和优化开发体验,而这就是 unvue 做的。和 Next.js/Nuxt.js 不同, unvue 不要求你有固定的目录结构,和普通的 webpack 项目没多大区别,想怎么放都行,只要在 src/index.js export 一个 router 就行了:

    // your vue router instance
    import router from './router'
    
    export { router }
    

    然后在你的项目里执行:

    yarn add unvue
    yarn unvue -- dev
    

    打开 http://localhost:3000 就是一个完善的服务器端渲染的网站


    项目: https://github.com/egoist/unvue

    Demo: http://magnificent-heaven.glitch.me/ (妹子图)

    Demo 代码: https://glitch.com/edit/#!/join/3768925c-57df-41cb-8b2b-57afc8789beb (可以在线编辑运行)

    7 replies  •  2017-03-21 16:39:08 +08:00
    Alexisused
    Alexisused
    Mar 21, 2017 via Android
    1
    闲了试试
    zaishanfeng
    zaishanfeng
    Mar 21, 2017
    2
    怎么配合 nginx
    nicoljiang
    nicoljiang
    Mar 21, 2017
    3
    它的意义是什么啊?
    sox
    sox
    OP
    Mar 21, 2017
    4
    @zaishanfeng 和普通 node.js server 一样
    yyy
    yyy
    Mar 21, 2017
    5
    能用 Koa 吗?
    sox
    sox
    OP
    Mar 21, 2017
    6
    yyy
    yyy
    Mar 21, 2017
    7
    @sox #5 👍赞,献上 star 和膝盖。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1041 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 22:04 · PVG 06:04 · LAX 14:04 · JFK 17:04
    ♥ Do have faith in what you're doing.