title: VueJS: How to dynamically execute Javascript from string?
body: <p>I'm writing a website using VueJS which allows (selected) users to add scripts that are automatically executed upon page load. Here's a sample text that a user might upload:</p>
  
  <pre><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/howler/2.0.5/howler.js"&gt;&lt;/script&gt;
  &lt;script&gt;
      var sound = new howler.Howl({
          src: ['./sample.mp3']
      )}.play();
  &lt;/script&gt;
  </code></pre>
  
  <p>This text is stored into a string after retrieving from API backend. The problem now is: I couldn't get it to execute however I try. Is there an option in VueJS that can automatically execute javascripts in strings?</p>
  
  <p>As a reference, here's my code:</p>
  
  <pre><code>var temp_arr = utils.preprocess(vm.chapterInfo.Content)
  vm.display = temp_arr[0]
  vm.control_script = console.log(temp_arr[1])
  
  // None of below worked
  eval(vm.control_script)
  document.getElementsByTagName("head")[0].appendChild(control_script)
  </code></pre>