vuejs2

Checking auth token valid before route enter in Vue router

那年仲夏 提交于 2021-02-04 10:46:20
问题 I have a simple use case, where my application is using vue-router and vuex . Then store contains a user object which is null in the beginning. After the user is validated from the server it sends back an user object which contains a JWT auth token which is assigned to the user object in the store. Now lets assume that the user came back after 3 hours and tried to visit a route or perform any other action, considering that the auth token has expired by then, what would be the best way to

Move vuetify styles to css file when server side rendering

二次信任 提交于 2021-01-29 21:32:55
问题 I've been using vuetify as frontend, but since I moved to nuxt. All styles are displayed within html page. Is there a way to move vuetify styles to separate css files? 回答1: You need to use extractCSS property from nuxt.config export default { build :{ extractCSS: true } } 来源: https://stackoverflow.com/questions/55936112/move-vuetify-styles-to-css-file-when-server-side-rendering

Is there a way to shorten defining v-model data, Vue.js and Laravel

徘徊边缘 提交于 2021-01-29 18:28:21
问题 On my edit page of CRUD project, I have a code that fills the form with values of which record is being edited. I use v-model to define HTML inputs, but the code seems too long. I get the data from the prop, and fill the v-model . My code that fills v-model created() { this.studentData = this.student; this.first_name = this.student.first_name; this.last_name = this.student.last_name; this.student_number = this.student.last_name; this.phone_number = this.student.phone_number; this.email = this

How to get source code from compiled file of vuejs?

≯℡__Kan透↙ 提交于 2021-01-29 18:28:16
问题 I lost my vuejs source code due to of laptop crash. I have files which are compiled by vuejs. Is it possible to get source code from compiled file (files genereated by npm run build in vuecli 2). I googled it but nothing found. Is there any tool to do so? 回答1: I found two links for you, First solution is to use babel (quite difficult) : https://forum.vuejs.org/t/any-method-or-workaround-to-decompile-dynamically-compiled-components/16334/3 Second solution (the best approach), if your compiled

Redirect authenticated users nuxt js

孤者浪人 提交于 2021-01-29 18:25:40
问题 I have the following code from my state to handle the login request and load the incoming data to state. export const state = { userId: "", token: "", authenticated: false }; export const getters = {}; export const actions = { async login({ commit, dispatch }, formData) { //codes to get data from server goes here // incoming datas are {status: true,token: 'token123', userId: '123'} const remainingMilliseconds = 60 * 60 * 1000; const expiryDate = new Date(new Date().getTime() +

I'm upgrading the Vuetify version from 1.5 to 2.0, but the previously installed plugin is no longer visible in the project

China☆狼群 提交于 2021-01-29 17:15:41
问题 old vuetify plugins not showing, but new vuetify plugins appear.v-checkbox as an example. can you help me v-checkbox is not visible **Vuetify JS After 2.0 update** // v2.0 // src/plugins/vuetify.js // follow official document import Vue from 'vue'; import Vuetify from 'vuetify/lib'; Vue.use(Vuetify); export default new Vuetify({ dark: true, // it's decide your project themes: { light: { prime: '#df8421' }, dark: { prime: '#333' } }, icons: { iconfont: 'mdi', }, }); After 2.0 update main js Is

Vuetify css not applying in Heroku

人盡茶涼 提交于 2021-01-29 14:59:08
问题 I'm developing a rails app, that uses vue through webpacker. Inside of the vue app I import vuetify and vuetify.css like so: import Vue from 'vue' import Vuetify from 'vuetify' import VueRouter from 'vue-router' import 'vuetify/dist/vuetify.min.css' import App from '../app.vue' import Axios from 'axios' import VueAxios from 'vue-axios' import Vuex from 'vuex' Works fine locally, but when pushed to heroku it no longer works. The app deploys, and it appears like vuetify is included, but the

How to use Typescript global types declarations in Vue SFC?

可紊 提交于 2021-01-29 14:56:00
问题 In Vue2 + Typescript project I have global.d.ts file with some types like that: global.d.ts type Nullable<T> = T | undefined | null; It works fine (without explicitly types export/import) when using in regular .ts files: misc.ts const answer: Nullable<Answer> = null; But it doesn't work inside .vue files: component.vue <script lang="ts"> import Vue from 'vue'; export default Vue.extend({ data: () => ({ answer: null as Nullable<Answer> // 'Nullable' is not defined }) }); </script> Tripple

Access index in v-for when iterating over object

落花浮王杯 提交于 2021-01-29 13:00:34
问题 I am trying to access the index of an iteration in Vue's v-for binding. This is the object: const obj = { obj1: { some: 'data' }, obj2: { some: 'data' }, obj3: { some: 'data' } } and I'm looping over it: <li v-for="(object, index) in obj" :key="index">{{ object.some }}</li> The problem is that contrary to looping over an array the index variable in case of looping over an object like this does not hold the iteration index (e.g. 0 , 1 , 2 ) but actually holds the object name obj1 , obj2 , obj3

Access index in v-for when iterating over object

≯℡__Kan透↙ 提交于 2021-01-29 12:20:36
问题 I am trying to access the index of an iteration in Vue's v-for binding. This is the object: const obj = { obj1: { some: 'data' }, obj2: { some: 'data' }, obj3: { some: 'data' } } and I'm looping over it: <li v-for="(object, index) in obj" :key="index">{{ object.some }}</li> The problem is that contrary to looping over an array the index variable in case of looping over an object like this does not hold the iteration index (e.g. 0 , 1 , 2 ) but actually holds the object name obj1 , obj2 , obj3