You can't do what you are suggesting, but you could create a new Vue for each element matching your selector.
Each would hold it's own state.
const vues = document.querySelectorAll(".app");
Array.prototype.forEach.call(vues, (el, index) => new Vue({el, data:{message: "hello " + index}}))
Example.
If you wanted a shared state,
const vues = document.querySelectorAll(".app");
const each = Array.prototype.forEach;
const data = {
message: "hello world"
};
each.call(vues, (el, index) => new Vue({el, data}))
At which point you could do something like data.message = "new value"
and all the Vues would change.
Example 2.
This is just me playing around though. It might be advisable for you to just create one Vue and manage all your foo
s.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…