vuejs2

vue-router navigate to the same route and re-run mounted hook

為{幸葍}努か 提交于 2021-02-19 08:20:15
问题 How can I naviagte to the current route using router-link and re-run mounted hook? HTML <!-- Include the library in the page --> <script src="https://unpkg.com/vue/dist/vue.min.js"></script> <script src="https://unpkg.com/vue-router"></script> <!-- App --> <div id="app"> <nav> <router-link :to="{ name: 'home' }" exact>Home</router-link> <router-link :to="{ name: 'about' }" @click.native.prevent="router.push({ name: 'about' })">About</router-link> </nav> <router-view :key="$route.fullPath"><

Run Vue.js and Laravel on the same server (same port)

半世苍凉 提交于 2021-02-19 05:38:13
问题 I am developing a website using Laravel as backend and Vue.js 2 as frontend. Now everytime i want to run my website I have to use 2 command: php artisan serve This will run the laravel server on port 8000 npm run dev This will run the vue.js server on port 8080 Can I just run them on the same server (same port), with just one command only?? 回答1: If you use the Laravel app with Vue.js included in it, you don't need to run npm run dev . In your case, you seem to have a decoupled frontend and

Passing data from PHP/HTML to .vue Component

喜欢而已 提交于 2021-02-19 05:18:06
问题 What I'm trying to do is seemingly simple, but I can't seem to figure it out. Basically, I have 2 files: A PHP file with the following: ... <user-panel v-if="user.id && loaded" v-bind:user="user" v-bind:name="theUserName"></user-panel> ... A .Vue component file with the following (that gets compiled into another file): <template> <span id="userPanel" class="d-flex align-items-center"> <a href="#" role="button" class="user-dropdown-toggle"> <div class="logged-in d-flex align-items-center">

VueJS error Avoid mutating a prop directly

大憨熊 提交于 2021-02-18 21:53:09
问题 I'm trying to create a modal but I'm getting this error only when I close it: [Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop being mutated: "value" found in ---> <PanelDesconectarModal> at resources\assets\vue\PanelDesconectarModal.vue <VNavigationDrawer> <PanelDrawer> at resources\assets\vue\PanelDrawer.vue <VApp> <PanelRoot> at resources\assets

Computed property reactive to window.innerwidth in VueJS

匆匆过客 提交于 2021-02-18 20:29:54
问题 Basically, what I need is a computed property that returns true when the window.innerwidth is equal or lower than 768px and false when it's higher than 768px. What I did: computed: { isMobile() { if (window.innerWidth <= 768) { return true } return false } } But that computes that property only once, and if I resize the window later, it doesn't react to that change. What can I do? 回答1: Add an eventlistener to the window like so: new Vue({ el: "#app", data() { return { windowWidth: window

On key press of Enter, click a button in vuejs

左心房为你撑大大i 提交于 2021-02-18 20:29:27
问题 Here is my fiddle: DEMO There is a button called "fb-send", which has to get clicked on key press on "enter" in the input field. How to achieve this? <input @keyup.enter="" placeholder="Reply here" class="fb-comment-input" /> <i class="material-icons fb-button-right fb-send">⇨</i> Any help would be much appreciated. Thank you. 回答1: You can also call method for fb_send directly on input field: @keyup.enter="enterClicked()" 回答2: Here is my answer fiddle: ANSWER-DEMO I solved this using $refs.

Laravel Vue Non SPA - How to split the files for every page for its vue js components?

帅比萌擦擦* 提交于 2021-02-18 13:00:10
问题 My application is using laravel vue but not SPA,.. so im still using laravel blades to separate the pages. Every page are importing app.js. My App.js is compiled by webpack and all my vue components are compiled on that file. so the problem is the app.js getting MB size and the every page will slow to load that file. Is their way to split the code of vuejs or separate the file for every pages using webpack? this is my webpack.js in my web application. const mix = require('laravel-mix'); /* |-

Laravel Vue Non SPA - How to split the files for every page for its vue js components?

不问归期 提交于 2021-02-18 13:00:10
问题 My application is using laravel vue but not SPA,.. so im still using laravel blades to separate the pages. Every page are importing app.js. My App.js is compiled by webpack and all my vue components are compiled on that file. so the problem is the app.js getting MB size and the every page will slow to load that file. Is their way to split the code of vuejs or separate the file for every pages using webpack? this is my webpack.js in my web application. const mix = require('laravel-mix'); /* |-

nuxt.js - how to set css background image dynamicaly

青春壹個敷衍的年華 提交于 2021-02-18 12:11:03
问题 Im using Nuxt.js, and have a custom component. This component has css in the component that sets a background image using css. I've tried the following but I get an error when I run this. The error is: invalid expression: Invalid regular expression flags in Component <template> <section class="bg-img hero is-mobile header-image" v-bind:style="{ backgroundImage: 'url(' + image + ')' }"> <div class=""> <div class="hero-body"> <div class="container"> <h1 class="title"> {{ result }} </h1> <h2

nuxt.js - how to set css background image dynamicaly

浪子不回头ぞ 提交于 2021-02-18 12:09:43
问题 Im using Nuxt.js, and have a custom component. This component has css in the component that sets a background image using css. I've tried the following but I get an error when I run this. The error is: invalid expression: Invalid regular expression flags in Component <template> <section class="bg-img hero is-mobile header-image" v-bind:style="{ backgroundImage: 'url(' + image + ')' }"> <div class=""> <div class="hero-body"> <div class="container"> <h1 class="title"> {{ result }} </h1> <h2