Coder Social home page Coder Social logo

vue-php's Introduction

vue-php

使用php进行vue的服务端渲染方案

本地运行

$ git clone [email protected]:Joe3Ray/vue-php.git
$ cd vue-php
$ npm install
$ npm run build
$ npm test

项目文件说明

  • index.js: 将.vue编译成.js.php的脚本,编译出来的.js用于前端渲染,.php用于服务端的渲染
  • build.js: 批量将components中的各个组件调用index.js来编译的脚本
  • Vue_Base.php: 使用php实现的Vue基类,包含渲染功能
  • index.php: 调用php版的Vue组件class渲染出html字符串的示例
  • test.js: 单元测试脚本
  • componenets/**: 组件示例
  • vue-template-php-compiler: 根据vue-template-compiler修改而来,能够编译出php版本render函数的工具

Vue服务端渲染原理

img

使用限制

由于不同语言的限制,我们在使用vue-php进行服务端渲染时也有一些限制:

  • .vue文件中,组件的datacomponents属性必须单独放到<config>中,并且是json形式
  • template中模板使用js表达式时,不能调用函数,不能使用计算属性

接入

如果想要接入这一套vue-php的方案,需要在线下使用index.js.vue文件进行编译,将编译出来的.php上线到服务器,并且服务器端引入VNode.phpVue_Base.php

License

MIT

vue-php's People

Contributors

joe3ray avatar

Watchers

James Cloos avatar Chalermporn Posoppitakwong avatar  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.