Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 138163

How to pass Array to IFrame Element in Vue.js?

$
0
0

i need to pass an array to iframe window in vue. Before this, I managed to pass data to iFrame base on an answer in stackoverflow but the solution won't work for Array. Here's how i tried:

Vue Last Try:

<iframe :src="getMultipleMarkers"></iframe>

    getMultipleMarkers(){
        var markers = [this.reports];
        console.log(markers )
        return `http://127.0.0.1:8000/multipleMarakers.html?reports=${markers}`;
    },

I can pass value of 1 index of array like thismarkers[0][x]['created_at']. but i need whole array

Vue First Trye:

    getMultipleMarkers(){
        return `http://127.0.0.1:8000/multipleMarakers.html?reports=${this.reports}`;
    },

I passed all my data from like this method from above code but they wasn't array. passed data was like ${this.customData} => which customData had a string text.

And here's how i got data from vue in iFrame:

var params = location.href.split('?')[1].split('&');
data = {};
for (x in params)
{
    data[params[x].split('=')[0]] = params[x].split('=')[1];
}
console.log(data['reports']);

And the result for above code in console is like :

[object%20Object],[object%20Object],[object%20Object],[object%20Object]

which [object%20Object] are repeated base on array length. How can i pass my reports to iFrame element?

Edit 01 : Result of Mathew Berg's Solution

Uncaught SyntaxError: Unexpected token % in JSON at position 3

Console Log of markers :

enter image description here


Viewing all articles
Browse latest Browse all 138163

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>