Skip to main content

2 posts tagged with "vue.js"

View All Tags

· One min read
Hreniuc Cristian-Alexandru

If you have a PWA, you might want to make sure that the client is using the latest version of it. Here are the steps needed to do this using quasar framework:

1. Make sure that the service-worker.js is not cached by nginx

Add this configuration in your nginx:

location ~ service-worker.js$ {
#add_header X-debug-whats-going-on 3;
add_header Cache-Control "no-cache, no-store";
expires -1;
try_files $uri $uri/ =404;
#/service-worker.js; -> https://serverfault.com/a/505099
}

· One min read
Hreniuc Cristian-Alexandru

LE: 14th Sept 2022 - Use Vue3 and you no longer need actions and mutations. Use State Management with Reactivity API

1. When you want to commit to a state(using actions and mutations), do not pass multiple parameters to the commit method, they will have the value undefined. Create an object and pass it like that. This:

commit(types.UPDATE_JOB, index, title);

Will become this:

commit(types.UPDATE_JOB, {index: index, title: job.title});

2. Props that have default value:

export default {
props: {
prop_without_defaut_value: {},
prop_with_defaut_value: {
default: false // this is a bool value
},
prop_with_defaut_value_string: {
default: String
}
},
data() {
return {
var_name: false
}
}
}

3. Use mapActions and custom methods:

methods: Object.assign({},
/* If we want to use mapActions and other
custom methods this is the way to do it
otherwise it will give an error */
mapActions([
'action_1',
'action_2'
]), {
method_1() {
this.title = this.job.title;
this.edit_mode = !this.edit_mode;
},
method_2() {}
}
),