简体   繁体   English

如何在 vue.js 中使用对象?

[英]How to use objects with vue.js?

I am new to vue.js and I have some questions, looking at their docs我是 vue.js 的新手,我有一些问题,查看他们的文档

https://v2.vuejs.org/v2/guide/#Getting-Started 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.他们通过字符串选择器定义了一个 vue 实例。 Is there a way I can replace #app with a string of the whole template.有没有办法可以用整个模板的字符串替换#app

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 实例vue_containervue_item ,有没有办法可以设置 vue 实例以便我可以嵌套它们,例如:

vue_container.append('list', vue_item);

Thanks谢谢

They define a vue instance by a string selector.他们通过字符串选择器定义了一个 vue 实例。 Is there a way I can replace #app with a string of the whole template.有没有办法可以用整个模板的字符串替换#app。

You are looking for the template option: https://v2.vuejs.org/v2/api/#template您正在寻找template选项: 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 [...]其次,如果我有两个 vue 实例 vue_container 和 vue_item,有没有办法可以设置 vue 实例以便我可以嵌套它们 [...]

No. Vue uses components for nesting, please see here:不,Vue 使用组件进行嵌套,请看这里:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM