-
-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Need a mechanism to prevent some class properties being transformed to Vue data #98
Comments
You could use vanilla accessors and WeakMap to map vue instance and JS native data. const insMap = new WeakMap
class Foo .... {
@vanilla
get rawData(){
if(!insMap.has(this)){
insMap.set(this,{})
}
return insMap.get(this)
}
} |
Thanks for your suggestion. It works, but I don't think it's a elegant way. It's not "class style" and make the code a bit obscure. Is it possible to make @vanilla work on properties, just like this: class Foo ... {
@vanilla
private nondata: number = 0;
} |
It is possible. It may be implemented in next version, but I can't give you a certian time. |
Keep this open until we implement the feature. |
@ericlogic Did you try |
I'm not using Vue Composition API at all. could you give me an example of how to use it in a class-style component. |
Just wrap your object with import {markRaw} from 'vue'
import {...} from 'vur-facing-decorator'
@Component
class C extends Vue{
field = markRaw(yourObject)
onMounted(){
//or
this.field = markRaw(yourObject)
}
} |
Sory for my late reply. |
Sometimes we don't need all of the class properties to be transformed to Vue data. Actually, I'm in trouble with three.js. When I define a Scene as a class property(It's a very common practice), It is transformed to Vue data and wrapped by Vue so it can't be rendered by three.js any more.
You might suggest that define it as a global variable. But it is not a "class style" way.
So. I suggest to provide a mechanism(maybe a @Nondata decorator) to prevent some class properties being transformed to Vue data.
The text was updated successfully, but these errors were encountered: