1

I have html file which has 3 script tags. I want to put these script tags in my vue.js file. i have added the html div element to by vue js file and it is getting rendered. but i am just not able to load script from html into vue. Below is my html file.

<html>
  <body>
    <script type="text/javascript">
      mxBasePath = "../editors/pure";
    </script>
    <script type="text/javascript" src="../editors/pure/js/mxClient.js"></script>
    <script src="../editors/dist/main.js"></script>
  </body>
</html>

I have tried to add my scripts in the mounted section of vue. Below is my vue.js file

import * as client from '../editors/pure/js/mxClient.js'
import * as mains from '../editors/dist/main.js'
mounted () {
    var z = document.getElementById('geApp')

    let recaptchaScript = document.createElement('script')
      recaptchaScript.setAttribute('src', client)

      z.appendChild(recaptchaScript)
      let processes = document.createElement('script')
      processes.setAttribute('src', mains)

      z.appendChild(processes)
      let basepath = document.createElement('script')
    basepath.innertext = 'mxBasePath = "../editors/pure"'
    z.appendChild(basepath)

  },

But i am getting the error as file not found.. I solved the problem by importing the src file but now i am getting the error as "one of the functionality is not defined."

Please can anyone help me in adding the scripts to vue.js file

7
  • 1
    Have you already had a look at this question about js import into vue component? Commented Mar 30, 2020 at 7:20
  • yes i did from there only i tried the mounted section. but it doesnt work Commented Mar 30, 2020 at 7:22
  • My main problem is the mxBasePath = "../editors/pure"; in html file.. i am unable to load tat. and another script "src="../editors/dist/main.js"" is a build project using webpack Commented Mar 30, 2020 at 7:25
  • I think it may be possible that the variable mxBasePath is not yet defined when your javascript code is run. Hence you'd have to check that the variable is loaded before setting the value. If that does not help yet, please provide the full error message Commented Mar 30, 2020 at 7:50
  • ReferenceError: mxLoadResources is not defined is the full error msg. mxLoadResources resides in mxClient ...that is <script type="text/javascript" src="../editors/pure/js/mxClient.js"></script> Commented Mar 30, 2020 at 9:09

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.