inquid/yii2-vue

Vue for yii2 web application

Installs: 1 181

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 2

Forks: 22

Open Issues: 3

Type:yii2-extension

1.1 2020-10-01 02:50 UTC

This package is auto-updated.

Last update: 2024-04-16 09:58:44 UTC


README

for yii2 web application

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require inquid/yii2-vue "*"

or add

"inquid/yii2-vue": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code by :

<?php
use inquid\vue\Vue;
?>
<?php Vue::begin([
    'id' => "vue-app",
    'data' => [
        'userModel' => User::findOne(Yii::$app->user->id),
        'message' => "hello",
        'seen' => false,
        'todos' => [
            ['text' => "aa"],
            ['text' => "akbar"]
        ]
    ],
    'methods' => [
        'reverseMessage' => new yii\web\JsExpression("function(){"
                . "this.message =1; "
                . "}"),
    ]
]); ?>
    
    <p>{{ message }}</p>
    <button v-on:click="reverseMessage">Reverse Message</button>
    
    <p v-if="seen">Now you see me</p>
    
    
    <ol>
        <li v-for="todo in todos">
          {{ todo.text }}
        </li>
    </ol>
    
    <p>{{ message }}</p>
    <input v-model="message">
  
  
<?php Vue::end(); ?>