Giter Club home page Giter Club logo

vue-ssr-demo's Introduction

一、vue服务端渲染的基本实现

1、初始化项目
npm init -y
2、安装vue以及vue服务端渲染工具
npm install vue vue-server-renderer --save
3、尝试渲染vue实例,返回html字符串
npm server.js

二、使用服务器返回

4、使用服务器返回html字符串
npm install express --save
5、将html字符串输出到模板文件

建立一个模板html,会把new Vue的template注入到模板的固定注释节点【两端不能有空格】

<!--vue-ssr-outlet-->
6、使用node.js核心模块fs读取文件
fs.readFileSync('./index.template.html', 'utf-8')
7、给模板插值的方法

使用三个大括号包裹着,就可以原封不动的给模板插值

{{{ metas }}}

vue-ssr-demo's People

Watchers

James Cloos avatar yinYouShiRen avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.