0

I am new to vue.js and I have some questions, looking at their docs

https://v2.vuejs.org/v2/guide/#Getting-Started

var app = new Vue({
  el: '#app',
  data: {
    message: 'Hello Vue!'
  }
});

They define a vue instance by a string selector. Is there a way I can replace #app with a string of the whole template.

Secondly, if I have two vue instances vue_container and vue_item, is there a way I can set up the vue instances such that I can nest them, something like:

vue_container.append('list', vue_item);

Thanks

10
  • 2
    What is the use case for your first question? Why would you want to use an element that does not exist? Commented Jun 19, 2017 at 0:45
  • 4
    You cannot nest Vue instances. You can nest Vue components. Commented Jun 19, 2017 at 0:49
  • 1
    Not sure I understand that use case tbh, like the comment above says, Vue is about components; you nest components, and the virtual dom takes care of the rest. #app is just your entry point. Commented Jun 19, 2017 at 0:50
  • 1
    See Local Registration. You can use the components property in Vue instances and components Commented Jun 19, 2017 at 1:17
  • 1
    You also appear to be misunderstanding the el property. This is the existing element in your plain-old HTML document that Vue binds the instance to, eg <div id="app"></div> Commented Jun 19, 2017 at 1:19

1 Answer 1

1

They define a vue instance by a string selector. Is there a way I can replace #app with a string of the whole template.

You are looking for the template option: https://v2.vuejs.org/v2/api/#template

Secondly, if I have two vue instances vue_container and vue_item, is there a way I can set up the vue instances such that I can nest them [...]

No. Vue uses components for nesting, please see here:

https://v2.vuejs.org/v2/guide/components.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.