Can the data in the vue component be passed to index.html?

the company has a set of js code shared by Wechat, which is written in native js.
you can configure the titles, profiles, thumbnails and so on shared by Wechat

I use it in vue. I put the js link directly under index.html, and the configuration method is also written under index.html, so that it can be shared and used normally.
but now there is a requirement for users to obtain data from the API after operation, and then insert the data into the title and profile shared by Wechat.
I don"t know how the data in the vue component is transferred to index.html.

or is there any other way?

Dec.10,2021

Yes.
since you want to put the js link in index.html, why not write a dynamically loaded script tag in vue using native js and let it execute. If data transfer is troublesome, data transfer can be achieved with the help of sessionStorage.
of course, the best solution is not to pile it all in the index.html. When there is more business in it, it becomes more and more difficult to maintain.


although I don't quite understand your specific needs, I think we can consider using a callback function to pass variables to the native js in html.
clipboard.png


No problem at all. I pass values to the component in the index.html file, and I can even call methods in the component.

mainly borrows window objects.

in the component, in the created function, assign this to a global variable, and then index.html can get it.

remember to empty this variable after running out of index.html, otherwise the component may not be destroyed, resulting in a memory leak.

https://codeshelper.com/a/11.

my blog

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b38028-3448c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b38028-3448c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?