Table of Contents
1.模块化 or 单文件组件化 ?
2.前端vue与模板的关联方法:多blade模板 or 单个blade模板(PHP框架laravel自带模板引擎)?
1和2的问题将配合进行,并且里面可交叉,那哪一种是更好的方案呢?
回复内容:
Home Backend Development PHP Tutorial 关于在服务器端用vuejs,并希望能在服务器端把页面渲染出来的若干问题,谢谢

关于在服务器端用vuejs,并希望能在服务器端把页面渲染出来的若干问题,谢谢

Jun 06, 2016 pm 08:18 PM
laravel php vue.js

首页,我想我寻求的这个应该是个临界于依赖php模板渲染页面和SPA之间的一个过渡的方案吧,我打算把这一步步的变化都测试下;
也是继 http://segmentfault.com/q/1010000004067025 这个问题进一步的思考;

1.模块化 or 单文件组件化 ?

  • 在服务器端渲染的页面,用上vue的模块化或.vue单文件组件化来处理数据,输出的是完整的Html吗?还是说会传到客户端去渲染?

  • 主要是对于.vue的组件化的,把php出来的数据交给window(无法直接嵌入php数据),绑给vue,这会是在服务器端渲染吗?

  • 模块化还是可以直接嵌入php数据的话,那应该还是会输出html来吧?

  • 如果交给node层来渲染是不是直接就出了html?

2.前端vue与模板的关联方法:多blade模板 or 单个blade模板(PHP框架laravel自带模板引擎)?

  • 使用多个Blade模板渲染,但都包含同一个入口,然后每次去调用不同的组件来使用,是否会把多余的组件一同打包进来?是不是有更好地方法?

  • 使用单Blade模板渲染,对应多个入口,根据每次的不同参数引入不同入口从而来渲染页面,是否可行?

1和2的问题将配合进行,并且里面可交叉,那哪一种是更好的方案呢?

谢谢!可能说的有点乱,想试试这种过渡方案的具体实现方案。

回复内容:

首页,我想我寻求的这个应该是个临界于依赖php模板渲染页面和SPA之间的一个过渡的方案吧,我打算把这一步步的变化都测试下;
也是继 http://segmentfault.com/q/1010000004067025 这个问题进一步的思考;

1.模块化 or 单文件组件化 ?

  • 在服务器端渲染的页面,用上vue的模块化或.vue单文件组件化来处理数据,输出的是完整的Html吗?还是说会传到客户端去渲染?

  • 主要是对于.vue的组件化的,把php出来的数据交给window(无法直接嵌入php数据),绑给vue,这会是在服务器端渲染吗?

  • 模块化还是可以直接嵌入php数据的话,那应该还是会输出html来吧?

  • 如果交给node层来渲染是不是直接就出了html?

2.前端vue与模板的关联方法:多blade模板 or 单个blade模板(PHP框架laravel自带模板引擎)?

  • 使用多个Blade模板渲染,但都包含同一个入口,然后每次去调用不同的组件来使用,是否会把多余的组件一同打包进来?是不是有更好地方法?

  • 使用单Blade模板渲染,对应多个入口,根据每次的不同参数引入不同入口从而来渲染页面,是否可行?

1和2的问题将配合进行,并且里面可交叉,那哪一种是更好的方案呢?

谢谢!可能说的有点乱,想试试这种过渡方案的具体实现方案。

首先,vue 是客户端的,
如果要在服务端渲染 vue 的话,
也不是不行,得经过 nodejs 来弄,
现在还没有官方推荐的成熟方案。

laravel + vue 本质上是:
laravel 通过 blade 引擎渲染出 html,
返回给客户端执行 vue 的相应脚本。

解决的是 vue 本身没有或不大方便的 路由和权限验证

使用node+vue.js实现SPA应用,解决了SPA应用的最大缺点SEO 之前写的文章 现在在完善项目中。

.vue 文件 在服务器上没法加载 所以放弃使用了,
服务端渲染 可以用第3方写的vue-server插件

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1664
14
PHP Tutorial
1268
29
C# Tutorial
1248
24
The Continued Use of PHP: Reasons for Its Endurance The Continued Use of PHP: Reasons for Its Endurance Apr 19, 2025 am 12:23 AM

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

The difference between laravel and thinkphp The difference between laravel and thinkphp Apr 18, 2025 pm 01:09 PM

Laravel and ThinkPHP are both popular PHP frameworks and have their own advantages and disadvantages in development. This article will compare the two in depth, highlighting their architecture, features, and performance differences to help developers make informed choices based on their specific project needs.

Laravel framework skills sharing Laravel framework skills sharing Apr 18, 2025 pm 01:12 PM

In this era of continuous technological advancement, mastering advanced frameworks is crucial for modern programmers. This article will help you improve your development skills by sharing little-known techniques in the Laravel framework. Known for its elegant syntax and a wide range of features, this article will dig into its powerful features and provide practical tips and tricks to help you create efficient and maintainable web applications.

The Compatibility of IIS and PHP: A Deep Dive The Compatibility of IIS and PHP: A Deep Dive Apr 22, 2025 am 12:01 AM

IIS and PHP are compatible and are implemented through FastCGI. 1.IIS forwards the .php file request to the FastCGI module through the configuration file. 2. The FastCGI module starts the PHP process to process requests to improve performance and stability. 3. In actual applications, you need to pay attention to configuration details, error debugging and performance optimization.

Laravel vs. Python (with Frameworks): A Comparative Analysis Laravel vs. Python (with Frameworks): A Comparative Analysis Apr 21, 2025 am 12:15 AM

Laravel is suitable for projects that teams are familiar with PHP and require rich features, while Python frameworks depend on project requirements. 1.Laravel provides elegant syntax and rich features, suitable for projects that require rapid development and flexibility. 2. Django is suitable for complex applications because of its "battery inclusion" concept. 3.Flask is suitable for fast prototypes and small projects, providing great flexibility.

What happens if session_start() is called multiple times? What happens if session_start() is called multiple times? Apr 25, 2025 am 12:06 AM

Multiple calls to session_start() will result in warning messages and possible data overwrites. 1) PHP will issue a warning, prompting that the session has been started. 2) It may cause unexpected overwriting of session data. 3) Use session_status() to check the session status to avoid repeated calls.

What are the differences between yi2 and tp5 What are the differences between yi2 and tp5 Apr 18, 2025 pm 11:06 PM

With the continuous development of PHP framework technology, Yi2 and TP5 have attracted much attention as the two mainstream frameworks. They are all known for their outstanding performance, rich functionality and robustness, but they have some differences and advantages and disadvantages. Understanding these differences is crucial for developers to choose frameworks.

Using Laravel: Streamlining Web Development with PHP Using Laravel: Streamlining Web Development with PHP Apr 19, 2025 am 12:18 AM

Laravel optimizes the web development process including: 1. Use the routing system to manage the URL structure; 2. Use the Blade template engine to simplify view development; 3. Handle time-consuming tasks through queues; 4. Use EloquentORM to simplify database operations; 5. Follow best practices to improve code quality and maintainability.

See all articles