[Vuejs]-How to make use of Javascript variable which are defined on index.html/index.jsp to Vue.js?

0👍

I guess, the issue is with your environment. Here a checklist to find the error:

  • Make sure the javascript code var token = '****' is in your html source code (caching or a bug might get in the way)
  • Obviously, check if no errors occur during token initialization or Vue.prototype modification
  • Check if Vue.prototype.$csrfToken = token; is called after global variable initialization: your script with Vue might be included before the global variable being set.

And I should add that the pattern you’re using is not encouraged: see the official Vue docs over the usage of Instance Properties

Leave a comment