vue-router

How to pass props in vue router

孤者浪人 提交于 2019-12-25 01:46:38
问题 Hi guys i been trying to pass props in vue routes so far i was able to achieve this below, but is not what i wanted. So far this works route.js { path: '/register/', name: 'register', component: require('./views/Login').default, } home.vue <router-link tag="li" :to="{ name: 'register', params: { isRegisteringMe: 'true' }}" class="btn btn-green m-top-20 menu-btn" v-show="!isLoggedIn">Register</router-link> And in register.vue i can console.log(this.$route.params.isRegisteringMe); which will

VUE Router not working with two Electron BrowserWindows

丶灬走出姿态 提交于 2019-12-25 01:34:52
问题 I’m trying to create an app with two BrowserWindows using the same Vue App with vue-router, but the router aren’t working. I’m always receiving error ‘Cannot GET /’ for the second route. main\index.js var mainURL = `http://localhost:9080/` var secondURL = `http://localhost:9080/page2` function createWindow () { mainWindow = new BrowserWindow({ height: 600, width: 800 }) mainWindow.loadURL(mainURL) mainWindow.on('closed', () => { mainWindow = null }) secondWindow = new BrowserWindow({ height:

I'm losing data after clicking on About page in Vue

邮差的信 提交于 2019-12-25 00:55:21
问题 I have a Vue router installed and two pages: Home and About . All is working, but when I click to About page and then back, data from Home page is gone. Page not reloading, I'm just moving between routed pages. Props are passed to the component. Where is a mistake? Why data doesn't save in component after clicking About page? 回答1: This problem has been solved. Vuex was used. 来源: https://stackoverflow.com/questions/57240303/im-losing-data-after-clicking-on-about-page-in-vue

Error in render function: “TypeError: Cannot read property of undefined”, using Vuex and Vue Router

北城以北 提交于 2019-12-24 23:42:52
问题 I have been dealing with an issue using Vue, Vuex and Vue-Router. I'm building a flash cards app, fetching all the cards on main app creation, then using a Vuex getter to get each card by its id which is passed as a route parameter. Relevant bits: App.vue export default { components: { 'app-header': header, }, data() { return { } }, created() { this.$store.dispatch('getAllCards'); } } The dispatch('getAllCards') is just pulling all the cards from the DB and committing to Vuex store.js . Now I

Vuejs ssr check user is authenticated for each request

ぃ、小莉子 提交于 2019-12-24 22:11:21
问题 I’m using this ssr boilerplate for my app, https://github.com/vuejs/vue-hackernews-2.0 I don’t know how to implement logic for checking is user authenticated for each user’s page request, I’m using cookies for storing user's token I looked that router can handle request before render component: router.beforeEach((to, from, next) => { if (to.matched.some(record => record.meta.requiresAuth)) { // this route requires auth, check if logged in // if not, redirect to login page. // isLoggedIn() //

Vuejs lazy loading routes in webpack template

送分小仙女□ 提交于 2019-12-24 20:24:01
问题 I have created vuejs project with vue-cli tools and webpack template. vue init webpack my-project I don't know how to implement lazy loading on routes with templates currently i have two routes in router/index.js import Vue from 'vue' import Router from 'vue-router' import HelloWorld from '@/components/HelloWorld' import Test from '@/components/Test' Vue.use(Router) export default new Router({ mode: 'history', routes: [ { path: '/', name: 'HelloWorld', component: HelloWorld }, { path: '/test'

Vue项目如何刷新当前页面

别来无恙 提交于 2019-12-24 18:06:51
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 一、场景: 项目需求是:在课程详情页 点击 相关课程 还在当前页面看此课程详情; 功能实现:这时候点击相关课程需要重新加载刷新当前路由 二、’解决的办法及遇到的问题 this.$router.go(0)。这种方法虽然代码很少,只有一行,但是体验很差。页面会一瞬间的白屏,体验不是很好 用vue-router重新路由到当前页面,页面是不进行刷新的。 .location.reload()。这种也是一样,画面一闪,体验不是很好 三、推荐解决方法: 用 provide / inject 组合 原理:允许一个祖先组件向其所有子孙后代注入一个依赖,不论组件层次有多深,并在起上下游关系成立的时间里始终生效 1.在App.vue,声明reload方法,控制router-view的显示或隐藏,从而控制页面的再次加载。 <template> <div id="app"> <router-view v-if="isRouterAlive"/> </div> </template> <script> export default { name:"app", provide(){ return{ reload:this.reload } }, data(){ return{ isRouterAlive:true //控制router

Vuepress inside and integrated with Vue project

回眸只為那壹抹淺笑 提交于 2019-12-24 15:55:04
问题 I´m starting with Vuepress (https://vuepress.vuejs.org), and i´d followed the docs to integrate it with an existing project (https://vuepress.vuejs.org/guide/getting-started.html#inside-an-existing-project). I used the sugested docs directory. But now i need to "really" integrate with my project and i need to when my users access the my-project.com/docs, to reach the Vuepress docs If i make (yarn docs:build), the /dist folder will be generated to be used anywhere as a statics HTML files. I

Vue template compiler 的问题

人盡茶涼 提交于 2019-12-24 14:45:22
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> [Vue warn]: You are using the runtime-only build of Vue where the template compiler is not available. Either pre-compile the templates into render functions, or use the compiler-included build. 转载自: https://segmentfault.com/a/1190000006435886 解决办法:添加package.config.js配置文件中,添加本文章的红色部分代码 import vue 顺利安装完成并按 changelog 做了修改之后,启动项目也正常,当我兴致勃勃地打开 Browser,驾轻就熟地输入 localhost,并自然而然地按下 Enter,一切水到渠成。 然而,迎接我的竟是一片白板,控制台里赫然映着一串红字。 [Vue warn] : You are using the runtime-only build of Vue where the template option is not available. Either pre-compile the templates into render

Triggering a route only after dispatch and commit completed in VueJS

六眼飞鱼酱① 提交于 2019-12-24 13:33:37
问题 I do have a form submit which takes email and password then pass them into an action in store called userSignIn SignIn.vue : onSubmit () { if (this.$refs.form.validate()) { const user = { email: this.email, password: this.password } this.$store.dispatch('userSignIn', user) .then(() => { this.$router.push('/') }).catch(err => { console.log(err) }) } } Within store, I do have a userSignIn action like this store.js actions: userSignIn ({commit, getters}, payload) { getters.Api.post(`user/signin`