How to pass an object as props with vue router?

It can work by using props’s Function mode and params Vue 2 demo: https://jsfiddle.net/hacg6ody/ when adding routes, use props’s Function mode so that it has a default property user and it will add route.params as props. { path: ‘/create’, name: ‘create’, component: CreateComponent, props: (route) => ({ user: userData, …route.params }) } params passed in … Read more

Importing javascript file for use within vue component

Include an external JavaScript file Try including your (external) JavaScript into the mounted hook of your Vue component. <script> export default { mounted() { const plugin = document.createElement(“script”); plugin.setAttribute( “src”, “//api.myplugincom/widget/mykey.js” ); plugin.async = true; document.head.appendChild(plugin); } }; </script> Reference: How to include a tag on a Vue component Import a local JavaScript file In … Read more

Get element height with Vuejs

The way you are doing it is fine. But there is another vue specific way via a ref attribute. mounted () { this.matchHeight() }, matchHeight () { let height = this.$refs.infoBox.clientHeight; } <div class=”columns”> <div class=”left-column” id=”context”> <p>Some text</p> </div> <div class=”right-column” id=”info-box” ref=”infoBox”></> <img /> <ul> some list </ul> </div> </div> In this case, … Read more

Is there any way to ‘watch’ for localstorage in Vuejs?

localStorage is not reactive but I needed to “watch” it because my app uses localstorage and didn’t want to re-write everything so here’s what I did using CustomEvent. I would dispatch a CustomEvent whenever you add something to storage localStorage.setItem(‘foo-key’, ‘data to store’) window.dispatchEvent(new CustomEvent(‘foo-key-localstorage-changed’, { detail: { storage: localStorage.getItem(‘foo-key’) } })); Then where ever … Read more

Force download GET request using axios

You’re getting empty PDF ’cause no data is passed to the server. You can try passing data using data object like this axios .post(`order-results/${id}/export-pdf`, { data: { firstName: ‘Fred’ }, responseType: ‘arraybuffer’ }) .then(response => { console.log(response) let blob = new Blob([response.data], { type: ‘application/pdf’ }), url = window.URL.createObjectURL(blob) window.open(url) // Mostly the same, I … Read more

Is it possible to pass a component as props and use it in a child Component in Vue?

Summing up: <!– Component A –> <template> <div class=”A”> <B> <component :is=”child_component”></component> </B> </div> </template> <script> import B from ‘./B.vue’; import Equipment from ‘./Equipment.vue’; export default { name: ‘A’, components: { B, Equipment }, data() { return { child_component: ‘equipment’ }; } }; </script> <!– Component B –> <template> <div class=”B”> <h1>Some content</h1> <slot></slot> <!– … Read more

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