Answer the question
In order to leave comments, you need to log in
How to include templates in Vue.js and another question about the application structure?
I started learning JavaScript and along the way Vue.js 1. I use the vuejs.github.io/vue-router/en/basic.html
router
.
var Foo = Vue.extend({
template: '<p>This is foo!</p>'
})
var Guestbook = Vue.extend({
template: '<div id="guestbook" style="width: 450px">' +
'<h3>Новый комментарий</h3>'+
'<form v->' +
'<div class="form-group">' +
'<label for="">Ваше имя</label>'+
'<input type="text" class="form-control">' +
'</div>'+
'<div class="form-group">' +
'<label for="">Комментарий</label>'+
'<textarea class="form-control"></textarea>' +
'</div>'+
'<div class="form-group">' +
'<button type="submit" class="btn btn-success">Отправить</button>'+
'</div>'+
'</form>'+
'<h2>Комментарии</h2>' +
'<article v-repeat="comment: comments">' +
'<h3>{{comment.name}}</h3>' +
'<p>{{comment.content}}</p>' +
'</article>' +
'</div>'
});
Answer the question
In order to leave comments, you need to log in
var Foo = Vue.extend({
template: '#view1'
})
var Bar = Vue.extend({
template: '#view2'
})
<div class="hiden">
<div id="view2">
......
</div>
<div id="view2">
...
</div>
</div>
Use single-file components - https://ru.vuejs.org/v2/guide/single-file-componen... - it's more convenient
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question