Currently, I am developing a website with VueJS that enables selected users to upload scripts for automatic execution upon page load. For instance, here is an example of the type of script a user may input:
<script src="https://cdnjs.cloudflare.com/ajax/libs/howler/2.0.5/howler.js"></script>
<script>
var sound = new howler.Howl({
src: ['./sample.mp3']
)}.play();
</script>
After fetching this text from the API backend, it is stored in a string. However, I have encountered difficulty in getting it to execute properly. Is there a feature within VueJS that can handle executing JavaScript code within strings automatically?
For your information, below is a snippet of my code:
var temp_arr = utils.preprocess(vm.chapterInfo.Content)
vm.display = temp_arr[0]
vm.control_script = console.log(temp_arr[1])
// Unfortunately, none of the methods below have been successful
eval(vm.control_script)
document.getElementsByTagName("head")[0].appendChild(control_script)