Vue: Plugin global property cannot be used in computed

Created on 1 Oct 2017  路  3Comments  路  Source: vuejs/vue

Version

2.4.4

Reproduction link

https://jsfiddle.net/0epfuvja/3/

Steps to reproduce

  • Define global Vue property in custom plugin.
  • Define instance property which reads data from global property.
  • Load plugin.
  • In application declare computed property which reads data from plugin instance's propety.
  • Create application.
  • Change global Vue property.
  • Watch computed property.

What is expected?

Computed property result new value.

What is actually happening?

Computed property doesn't change. Vue also not do template re-render.

Most helpful comment

That's normal, vue makes things added onto data reactive, but if you add something to Vue that won't be reactive. Here you have an example doing what you want: https://jsfiddle.net/gd11d31y/ by creating a new Vue instance with some data

All 3 comments

That's normal, vue makes things added onto data reactive, but if you add something to Vue that won't be reactive. Here you have an example doing what you want: https://jsfiddle.net/gd11d31y/ by creating a new Vue instance with some data

@posva so how can I create reactive properties in plugin? Is it possible?

PS: In my application I have plugin in another file.

look at the fiddle. You can also look at other plugins like vuex to see how they achieve reactivity

Was this page helpful?
0 / 5 - 0 ratings

Related issues

paceband picture paceband  路  3Comments

franciscolourenco picture franciscolourenco  路  3Comments

julianxhokaxhiu picture julianxhokaxhiu  路  3Comments

wufeng87 picture wufeng87  路  3Comments

robertleeplummerjr picture robertleeplummerjr  路  3Comments