-
Notifications
You must be signed in to change notification settings - Fork 66
The default value should be undefined
instead of null
#13
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
Comments
Actually, I believe In as much as there is a semantic difference between Given that you have defined the async computed property, it certainly isn't undefined, even before the data is loaded, and so As to your second point: Remember that setting the default value as If you want to work around this by setting the default to |
I listened to my colleagues' opinions and referred to some articles on the web. They thought that the difference between
I understand what you mean, but for the computed property, I tend to think that it is a primitive value used when a variable has not been assigned a value, not emply or no-existent value In fact, computed property will only fill the value after the promise is complete, this is what the meaning of undefined The fact that I use the following code in my project to write data function new Vue({
data: () => ({
// means data is unclear
someData: undefine
}),
method: {
async loadData(){
try {
this.someData = (await this.$http.get('/someData')).data
} catch (e){
console.error(e);
// means no data
this.someData = null
}
}
}
}) The above is my understanding of their differences Artical references |
You're right that that's the difference, but I disagree about which one is You say In other words, between when you declare the computed property and between That's my opinion, anyway. But arguing about it is fruitless, and I think I A feature I've been planning (which I'll probably release soon in v3.1.0),
Then the default value would be |
That sound good, and i cant wait to do like this in my project with this feature 😊 |
I have now released version 3.1.0 of |
Such as title
Another problem: default value giving as undefined will be ignore, but set a function returning undefined, the plugin perform correct.
The text was updated successfully, but these errors were encountered: