[英]Vue.js 2 Confusion about data load
I am kind of new on Vue.我是 Vue 的新手。 I am working on a Vue.js 2.x app where I have the usual Vue Instance with all the methods, data and other properties.
我正在开发一个 Vue.js 2.x 应用程序,其中我有通常的 Vue 实例,其中包含所有方法、数据和其他属性。
For instance, I have the in the data the following properties:例如,我在数据中有以下属性:
data: {
users: []
}
In the /admin
page I use Vue to load only five users with a method loadUsers(5)
.在
/admin
页面中,我使用 Vue 使用loadUsers(5)
方法仅加载五个用户。 Where in the created hook I call this.users = this.loadUsers(5);
在创建的钩子中我称之为
this.users = this.loadUsers(5);
. .
But in the /users
page I load all the users within the same users variable.但是在
/users
页面中,我将所有用户加载到同一个用户变量中。 Right?正确的?
I am using a PHP framework's router, not Vue Router.
我使用的是 PHP 框架的路由器,而不是 Vue 路由器。
How should I separate different data for different pages?我应该如何区分不同页面的不同数据?
You could create separate Components per page.您可以为每页创建单独的组件。 They come in several different varieties, Single File , Local , and inline .
它们有几个不同的品种, Single File 、 Local和inline 。
I frequently opt for single file myself.我自己经常选择单个文件。 I like the separation and organization they come with.
我喜欢他们带来的分离和组织。 As you get further along look into Dynamic .
随着您进一步了解Dynamic 。 These are good swapping in and out a section of the page, but you're not limited by means.
这些是很好的换入和换出页面的一部分,但您不受手段的限制。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.