Reputation: 31
How to load divs from page 2 into page 1 with VueJs.
localhost/getnew
<html>
<head>
<title> title </title>
<body>
<div id="main">
<div id="content2"> this is content2</div>
<div id="content3"> this is content3</div>
</div>
</body>
</html>
I want to get and use the id content2 from getnew to create a div into home with the content of that div, after the link was clicked and deleted, and do the same with content3, content4 and successively.
localhost/homepage
<html>
<head>
<title> title </title>
<body>
<div id="main">
<div id="content1"> this is content1</div>
<a href="#"> get content</a>
</div>
</body>
</html>
And then would be like that.
<html>
<head>
<title> title </title>
<body>
<div id="main">
<div id="content1"> this is content1</div>
<div>this is content2</div>
<div>this is content3</div>
</div>
</body>
</html>
I'm new in VueJs and I have no idea how to do that. If someone can help. Thanks.
Upvotes: 3
Views: 332
Reputation: 90138
In Vue, like in most SPA's, the page (DOM) doesn't hold data.
The page is a rendering tool which displays data held in the source. The source can be:
vm.data()
(typically holding specific data for current component - it can be passed down to child components, though)If your data is not overly complex, you might be able to manage it without Vuex, using a simple state management pattern.
So, in a nutshell, you don't get the div with some #id
from one page to another. You just mutate the store and then everywhere that data is used it updates.
Upvotes: 2