Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

One option is to access the Vue instance through the global reference app and update the variable container using Vue's reactivity system.

For example:

// define Vue instance
var app = new Vue({
  data: {
    myVariable: 'initial value'
  }
});

// define a JavaScript function that is not a method of Vue.js
function myFunction() {
  // access the Vue instance
  app.myVariable = 'new value';
}

// call the function to update the variable container
myFunction();

In this example, app is the global reference to the Vue instance. The myFunction function accesses app and updates the myVariable data property using Vue's reactivity system. The updated value can then be accessed from any methods or templates within the Vue instance.