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

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

  •  
  •   sox ·
    egoist · Mar 20, 2017 · 7155 views
    This topic created in 3429 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
        1
    Alexisused  
       Mar 21, 2017 via Android
    闲了试试
    zaishanfeng
        2
    zaishanfeng  
       Mar 21, 2017
    怎么配合 nginx
    nicoljiang
        3
    nicoljiang  
    PRO
       Mar 21, 2017
    它的意义是什么啊?
    sox
        4
    sox  
    OP
       Mar 21, 2017
    @zaishanfeng 和普通 node.js server 一样
    yyy
        5
    yyy  
       Mar 21, 2017
    能用 Koa 吗?
    sox
        6
    sox  
    OP
       Mar 21, 2017
    yyy
        7
    yyy  
       Mar 21, 2017
    @sox #5 👍赞,献上 star 和膝盖。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   888 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 19:07 · PVG 03:07 · LAX 12:07 · JFK 15:07
    ♥ Do have faith in what you're doing.