承接 arrilot/vue-templates-in-php 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

arrilot/vue-templates-in-php

Composer 安装命令:

composer require arrilot/vue-templates-in-php

包简介

A simple package to manage vue components' templates in php

关键字:

README 文档

README

Latest Stable Version Total Downloads Build Status

Vue templates in PHP

Introduction

There are two main ways to deal with vue components' templates:

  1. Single file components
  2. <script type="text/x-template">

Single files components are great, but they have their own problems:

  1. You need a decent build setup.
  2. You can't manage templates from php directly. If this is not an issue for you - go with them, you don't need this package then. Otherwise this small packages can help you to set up <script type="text/x-template"> scheme in a simple and maintainable way.

Installation

  1. composer require arrilot/vue-templates-in-php

Usage

First of all create a helper like that

function vue()
{
    static $vue = null;

    if ($vue === null) {
        $vue = new \Arrilot\VueTemplates\TemplateManager('/absolute/path/to/directory/where/you/want/to/store/templates/');
    }

    return $vue;
}

or place TemplateManager object in a Service Container if you have one.

Add

<?php vue()->printTemplates() ?>

somewhere in footer above a script that starts vue application.

Now you can start making templates. For example let's imagine that you want to create a component for main menu.

  1. Create a component without template somewhere in js.
  2. Create a main-menu.php file inside the directory you passed to TemplateManager. This is a component template. You don't need to add any <script type="text/x-template"> or <template> tags to it. It's done behind the scenes.
  3. Register this template on pages where you need it - vue()->addTemplate('main-menu').
  4. Now you can reference it in a vue component you have created in step 1 like that: template: '#vue-main-menu-template'

统计信息

  • 总下载量: 853
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-04-01

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固