vue-router

Vue+Webpack app deploy on heroku not working when page is refreshed

早过忘川 提交于 2020-08-08 06:10:21
问题 I generated a vue app using vue-cli with webpack template and deployed it to heroku using this guide. I was able to run it without problem but when I refresh the page, or I accessed a sub route directly it fails. server.js var express = require('express') var path = require('path') var serveStatic = require('serve-static') app = express() app.use(serveStatic(__dirname)) var port = process.env.PORT || 5000 app.listen(port) console.log('server started '+ port) router.js My vue router config

Vue+Webpack app deploy on heroku not working when page is refreshed

走远了吗. 提交于 2020-08-08 06:10:07
问题 I generated a vue app using vue-cli with webpack template and deployed it to heroku using this guide. I was able to run it without problem but when I refresh the page, or I accessed a sub route directly it fails. server.js var express = require('express') var path = require('path') var serveStatic = require('serve-static') app = express() app.use(serveStatic(__dirname)) var port = process.env.PORT || 5000 app.listen(port) console.log('server started '+ port) router.js My vue router config

Vue warn $listeners and $attrs is readonly

試著忘記壹切 提交于 2020-08-07 21:06:17
问题 I am getting a lot of Vue warnings saying $listeners is readonly or $attrs is readonly and related to different Bootstrap items or to . For example: [Vue warn]: $attrs is readonly. found in ---> <BDropdown> <Display> <App> <Root> I am very sure it has something to do with loading the Vue instance twice somehow, but I don't really know, how to do it any other way, so that the routing still works. In my main.js the code is as follows: import Vue from 'vue' import App from './App' import router

前后端分离如何做权限控制设计?

风格不统一 提交于 2020-08-07 16:21:34
作者:薛҉定҉谔҉的҉猫҉ www.yuque.com/zhanghaofei/blog/xrpz9p 近几年随着react、angular、vue等前端框架兴起,前后端分离的架构迅速流行。但同时权限控制也带来了问题。 网上很多前、后端分离权限仅仅都仅仅在描述前端权限控制、且是较简单、固定的角色场景,满足不了我们用户、角色都是动态的场景。 且仅仅前端进行权限控制并不是真正意义的权限控制,它只是减少页面结构暴露、增强用户体验的功效。 场景 系统为后台管理系统,包含了用户创建、用户登录、用户管理自己的资源。用户经常会新增、删除,也可以根据工作情况随时调整页面、功能权限,所以采用用户-角色-页面权限方案实现。 为什么不行: 根据前端路由表显示左侧菜单,但vue-router的路由表主要为了组织代码,经常我们所需要的菜单并非一致。比如某个前端路由a子路由有b、c,但菜单中我们想要直接一级菜单就显示b、c或者将b、c各放到其他菜单下。所以这种非常不灵活。 一个路由是菜单还是页面?是否需要显示到菜单中?是否验证权限?哪个角色或者用户拥有权限?这些都需要写到前端路由里面,一旦有任何权限变动就要大量调整代码。 如果权限写死在前端,那么角色或者用户必须已知且固定不变。比如页面1的meta增加属性标识可访问的角色为a和b 页面 一个页面即一个前端页面,比如首页、用户管理页、资源管理页等。 基本思路为

vue-router — Uncaught (in promise) Error: Redirected from “/login” to “/” via a navigation guard

大城市里の小女人 提交于 2020-08-06 07:53:53
问题 Why is vue-router giving me this error? To be clear, the login flow works as intended but I want to a) get rid of the errro and b) understand why the error is happening. Error: Uncaught (in promise) Error: Redirected from "/login" to "/" via a navigation guard. Login flow start logged out, but enter a URL that requires auth (i.e. anything besides "/login") get redirected to "/login" (as expected). login successfully get redirected to starting Url from step #1, except with the above error.

Load routes from api in vue

有些话、适合烂在心里 提交于 2020-08-05 07:23:20
问题 I'm trying to load routes in a Vue application from my API. I tried pushing data to routes variable and using addRoutes method. But no luck. I think there could be an issue with async. But why the addRoutes() not working? Here's my code: import Vue from 'vue'; import VueRouter from 'vue-router'; import axios from 'axios'; /** * Routes */ import item_index from '../../app/Tenant/Item/Views/Index.vue'; import contact_index from '../../app/Tenant/Contact/Views/Index.vue'; import eav_index from '

在Ant-design-pro框架中引入jQuery和jQuery-ui步骤

混江龙づ霸主 提交于 2020-08-05 01:50:45
1.安装jQuery和jQuery-ui npm i jquery s npm i jquery - ui s yarn install 2.在vue.config.js中进行配置 // webpack build externals const prodExternals = { vue: 'Vue' , 'vue-router': 'VueRouter' , vuex: 'Vuex' , axios: 'axios' , jquery: 'jquery', // 新添加 $: 'jquery' // 新添加 } 3.在需要引入的组件中引入 <script> import jsplumb from 'jsplumb' import $ from "jquery" // 需要注意的是,在jquery-ui引入的时候, // 直接写成 import juqery-ui 是没有效果的,只能直接写到具体的方法 import 'jquery-ui/ui/widgets/draggable' import 'jquery-ui/ui/widgets/droppable' export default { name: 'test1' , components: { jsplumb }, mounted(){ /* global jsPlumb */ var instance = jsPlumb

How to slug an url using Vuejs

萝らか妹 提交于 2020-08-04 10:29:10
问题 I'm building a website with several articles. I'm using Vue Router, and for the moment the urls of my articles look like /article/id, for example : http://localhost:8080/article/85 . How can I slug an URL with the article title so it can be http://localhost:8080/article/the-article-title for example ? I have no idea what kind of code should I provide so here is my article route : routes: [ { path: '/article/:id', component: require('../components/articlePage.vue').default, name: 'article',

Nuxt open link into modal

谁都会走 提交于 2020-08-04 08:08:41
问题 I'm building a Nuxt application that has a list of products and clicking on one of them open a dedicated page of the product. It is working fine. Structure is: /pages/featured // directory of products /pages/product/:id/:slug // Dedicated product page Now I wish to add a new feature: I wish to keep the dedicated page of the product if clicked from a page that is not the directory of the products or if people land directly on it; I wish to open an almost full-screen dialog of the product on

Vue Router this.$router.push not working on methods

旧时模样 提交于 2020-08-02 06:50:31
问题 i'm doing login, but after the login methods gets success, i'm pushing a route for the $router object and it's not working, can someone help me? my code: doLogin(){ this.attemptLogin({...this.user}).then(function(){ this.$router.push('/') } ) }, So, the login methods execute as expected, but the callback this.$router.push('/') does not runs my attemptLogin is an action, it's code is following: export const attemptLogin = ( {commit}, user) => { return http.post('login', { 'email': user.email,