Vue.js – Making helper functions globally available to single-file components

inside any component without having to first import them and then prepend this to the function name What you described is mixin. Vue.mixin({ methods: { capitalizeFirstLetter: str => str.charAt(0).toUpperCase() + str.slice(1); } }) This is a global mixin. with this ALL your components will have a capitalizeFirstLetter method, so you can call this.capitalizeFirstLetter(…) from component … Read more

Do we have router.reload in vue-router?

this.$router.go() does exactly this; if no arguments are specified, the router navigates to current location, refreshing the page. note: current implementation of router and its history components don’t mark the param as optional, but IMVHO it’s either a bug or an omission on Evan You’s part, since the spec explicitly allows it. I’ve filed an … Read more

How to set URL query params in Vue with Vue-Router

Here is the example in docs: // with query, resulting in /register?plan=private router.push({ path: ‘register’, query: { plan: ‘private’ }}) Ref: https://router.vuejs.org/en/essentials/navigation.html As mentioned in those docs, router.replace works like router.push So, you seem to have it right in your sample code in question. But I think you may need to include either name or … Read more

Vue.js redirection to another page

If you are using vue-router, you should use router.go(path) to navigate to any particular route. The router can be accessed from within a component using this.$router. Otherwise, window.location.href=”https://stackoverflow.com/questions/35664550/some url”; works fine for non single-page apps. EDIT: router.go() changed in VueJS 2.0. You can use $router.push({ name: “yourroutename”}) or just router.push(“yourroutename”) now to redirect. Documentation Note: … Read more

How to add external JS scripts to VueJS Components?

A simple and effective way to solve this, it’s by adding your external script into the vue mounted() of your component. I will illustrate you with the Google Recaptcha script: <template> …. your HTML </template> <script> export default { data: () => ({ ……data of your component }), mounted() { let recaptchaScript = document.createElement(‘script’) recaptchaScript.setAttribute(‘src’, … Read more

Vue.js – How to remove hashbang #! from url?

In Vue 3, you’d want to use createWebHistory for the history option. import { createRouter, createWebHashHistory } from ‘vue-router’ const router = createRouter({ history: createWebHashHistory(), // … }) In Vue 2, you’d want to set mode to ‘history’. const router = new VueRouter({ mode: ‘history’, // … }) Make sure your server is configured to … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)