Z
Z
ZaurK2017-10-19 10:27:54
Yii
ZaurK, 2017-10-19 10:27:54

How to connect vue.js to yii2?

Greetings! I decided to try Vue.js, but I can't connect vuejs to the yii2 project:
I wrote in AppAsset.php

public $js = [
      'js/vue.js',
      'js/vuejsscript.js',
    ];

In the vuejsscript.js file the content is
new Vue({
  el: '#app',
  data: {
    title: 'Hello, I am Vue!';
  }
});

and in the form, respectively
<div id="app">
    <p>{{ title }}</p>
</div>

But for some reason the following {{ title }} is displayed. Both vue.js and vuejsscript.js are included and accessible from the browser. Tell me what I'm doing wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
myxasa, 2017-10-19
@ZaurK

in view/ somewhere
$this->registerJsFile(' js file path ', ['depends' => 'app\assets\AppAsset']);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question