vue-router

vue-router跳转相同路径报错

笑着哭i 提交于 2019-12-05 18:56:27
import Vue from 'vue' import Router from 'vue-router' // hack router push callback const originalPush = Router.prototype.push Router.prototype.push = function push (location, onResolve, onReject) { if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject) return originalPush.call(this, location).catch(err => err) } Vue.use(Router) 来源: https://www.cnblogs.com/xinchenhui/p/11939542.html

VueJs - Passing query in query string as prop

自闭症网瘾萝莉.ら 提交于 2019-12-05 18:54:33
I'm having an issue getting the URL query string from within a component. I am trying to implement this https://router.vuejs.org/guide/essentials/passing-props.html#function-mode so I can pass the query as a prop. I haven't used query strings much, and I tend to use params, but I need the query string in this case. The problem I am having is mounted() doesn't seem to have access to the query. Below is a basic sample of what I can't get working: URL = http://localhost:8080/?q=This%20is%20my%20query Router.js { path: '/', component: () => import('./App.vue'), props: (route) => ({ query: route

Error in render function: “TypeError: Cannot read property of undefined” in Vue

一曲冷凌霜 提交于 2019-12-05 17:44:49
I am using Laravel and vue-router. <template> <div class="content__inner"> <div class="forums"> <!-- Heading --> <div class="forums__heading" :style="'border-bottom:2px solid #' + board.category.color"> <div class="lg-8 md-8 sm-12 column column__first"> <h2 class="forums__heading__title">{{ board.title }}</h2> </div> <div class="lg-1 md-1 sm-1 dtop column text-center"> <strong>Replies</strong> </div> <div class="lg-3 md-3 sm-4 column text-right"> <strong>Latest Reply</strong> </div> <div class="clearfix"></div> </div> <!-- Content --> <div class="forums__content"> {{ board.category }} </div> <

Firebase Auth and Vue-router

家住魔仙堡 提交于 2019-12-05 16:57:49
问题 I'm trying to authenticate a Vue.js app using firebase. I have an issue where if trying to access a login-protected URL directly while logged in, the router will load and check for auth state before firebase.js has time to return the auth response. This results in the user being bounced to the login page (while they are already logged in). How do I delay vue-router navigation until auth state has been retrieved from firebase? I can see that firebase stores the auth data in localStorage, would

call a function every time a route is updated vue.js

牧云@^-^@ 提交于 2019-12-05 16:18:46
I have integrated intercom in my app and I need to call window.Intercom('update'); every-time my url changes. I know I could add it on mounted() but I rather not modify all my component and do it directly using the navigation guards . (Mainly to avoid to have the same code in 10 different places. At the moment I have: router.afterEach((to, from) => { eventHub.$off(); // I use this for an other things, here is not important console.log(window.location.href ) // this prints the previous url window.Intercom('update'); // which means that this also uses the previous url }) This runs intercom(

vue路由配置

梦想的初衷 提交于 2019-12-05 15:34:52
首先安装vue路由 cnpm install vue-router 接着在src目录下创建一个router.js文件 在router.js中引入vue-router import Router from 'vue-router'; import Vue from 'vue'; 如下图所示 注:resolve => require([],resolve)为懒加载 可以封装成一个公共函数引入到router.js中就不用重复书写 可以在routes中写上mode:"history"去掉地址中的“#” 最后在main.js中引入router 来源: https://www.cnblogs.com/wazy999/p/11931514.html

vue-router route with params not working on page reload

天涯浪子 提交于 2019-12-05 14:04:36
I am using vue-router on my project. I am able to navigate to my named routes perfectly fine. My only problem is when I use a named route which expects a parameter, it does not load when I refresh the page. here is my route: '/example/:username': { name: 'example-profile', title: 'Example Profile', component: ExampleComponent } this is how I am using the vue-router route : <a v-link="{ name: 'example-profile', params: { username: raaaaf } }"> Example Link </a> When I select Example Link I get mydomain.com/example/raaaaf . On first load, it renders the correct template, but when I refresh or

Vue.js - two different components on same route

杀马特。学长 韩版系。学妹 提交于 2019-12-05 13:32:13
I'm trying to figure out how to have 2 different components on same route with Vue. Main page or login page, depends if user is authenticated. Maybe im missing something in documentation, but i cant and cant figure it out. Is it even possible? Thx use auth param in router map: router.map({ '/home': { component: Home, auth: true }, '/login': { component: Login }, '/something': { component: Something, auth: true }, }) and then check before each transition: router.beforeEach(function (transition) { if (transition.to.auth && !auth.user.authenticated) { transition.redirect('/login') } else {

Vue test-utils how to test a router.push()

断了今生、忘了曾经 提交于 2019-12-05 12:05:12
In my component , I have a method which will execute a router.push() import router from "@/router"; // ... export default { // ... methods: { closeAlert: function() { if (this.msgTypeContactForm == "success") { router.push("/home"); } else { return; } }, // .... } } I want to test it... I wrote the following specs.. it("should ... go to home page", async () => { // given const $route = { name: "home" }, options = { ... mocks: { $route } }; wrapper = mount(ContactForm, options); const closeBtn = wrapper.find(".v-alert__dismissible"); closeBtn.trigger("click"); await wrapper.vm.$nextTick();

Vue router server configuration for history mode on nginx does not work

最后都变了- 提交于 2019-12-05 12:00:58
I read the following note from vue router documentation Note : when using the history mode, the server needs to be properly configured so that a user directly visiting a deep link on your site doesn't get a 404. So, I try to configure my nginx like the following server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; root /var/www/laravel/public/; index index.php index.html index.htm; server_name working.dev; location /user { rewrite ^(.+)$ /index.php last; } location / { try_files $uri $uri/ /index.php?$query_string; } location ~ \.php$ { try_files $uri /index.php =404;