javascript - Vue non reactive data available on instance -
i want store object in vue, should available entire instance , not reactive. (with reactive) use 'data' this:
new vue({ data: myobject })
but in fact myobject don't need change think making reactive bad. there method this?
you can use vue instance properties.
there may data/utilities you’d use in many components, don’t want pollute global scope. in these cases, can make them available each vue instance defining them on prototype:
vue.prototype.$appname = 'my app'
now $appname available on vue instances, before creation. if run:
new vue({ beforecreate: function () { console.log(this.$appname) } })
reference: link
or
you can use vuex state data property , define mutations if want change value.
Comments
Post a Comment