nuxt.js

NuxtJS Auth error with property doesn't exist

允我心安 提交于 2021-02-07 20:52:26
问题 I've just installed @nuxtjs/auth on my project. I get Property '$auth' does not exist on type 'AuthLoginPage' class. Method login on login class page this.$auth.loginWith('local', { data: { username: 'your_username', password: 'your_password' } }); My nuxt.config.ts modules: [ // Doc: https://axios.nuxtjs.org/usage '@nuxtjs/axios', '@nuxtjs/auth', '@nuxtjs/pwa', ], ... auth: { strategies: { local: { endpoints: { login: { url: 'http://127.0.0.1:3001/users/login', method: 'post', propertyName:

Keep scroll position when returning to page

陌路散爱 提交于 2021-02-07 14:15:00
问题 I have a long list on page A that I am scrolling through. When I visit another page and later return to page A, I want to be at the scroll position where I left. I have found this package for Vue (https://github.com/jeneser/vue-scroll-behavior), but I can't get it to work with NuxtJS. Any advice or ideas on how I best approach this? 回答1: You can alter the scroll behaviour on route change as described here https://nuxtjs.org/api/configuration-router#scrollBehavior by adapting it in nuxt.config

Access Nuxt plugins in .js files

帅比萌擦擦* 提交于 2021-02-07 08:38:18
问题 Let's say that I have a script file, foo.js : function doStuff() { // how to access store and other plugins here? } export default { doStuff } Without passing the calling component as an argument, how can I access things like app or installed plugins like store , i18n in a script file like the one above? 回答1: There are multiple ways to call custom function with this being a reference to the component it was invoked in. 1) Using mixins Custom function can be declared as a method and used

Use Vue Router In Script

微笑、不失礼 提交于 2021-02-05 12:18:27
问题 I have a script that will redirect a user to the login screen when they get a response code of 401 - which means their session has expired within the API. import axios from 'axios'; axios.interceptors.response.use(function (response) { return response; }, function(error) { if(error.response.status === 401) { localStorage.clear(); window.location = '/'; return Promise.reject(error); } return Promise.reject(error) }) I wish to use vue router instead of window.location to redirect to the login

Problem on manual page refresh due to params passed in the URL

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-05 08:19:10
问题 How do you all recommend page reloads (i.e. if a User presses refresh page) when using variables within the URL? I've generated a site statically with nuxt generate and am hosting it at http://www.wowrares.com/ . The site generates links properly and is able to navigate to the zone when clicking on the sidebar nav link, but if I were to manually enter http://www.wowrares.com/zone/Ashenvale , it says Page Not Found Looks like you've followed a broken link or entered a URL that doesn't exist on

Using Environment Variables in nuxt.config.js

不打扰是莪最后的温柔 提交于 2021-02-04 18:16:05
问题 I'm using Nuxt & Axios but having trouble using environment variables when building the application from my local machine . I have installed the @nuxtjs/dotenv module in an attempt to fix this issue but still having problems. Note: The environment variables work fine when building the app within my hosting providers environment. It is only building from my local machine that gives me trouble. My IDE is VS Code. Here is my axios setup inside nuxt.config.js: module.exports = { ... buildModules:

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

relative path in @nuxtjs/dotenv

馋奶兔 提交于 2021-01-29 16:32:06
问题 I am building an SSR nuxt.js project with laravel backend, and I want to share the .env for both laravel and nuxt. Here is my folder structure (base on a laravel folder structure but add a client folder to put nuxt) here is my nuxt.config.js module.exports = { srcDir: __dirname, buildModules: [ [ '@nuxtjs/dotenv', { path: '../' } ] ] } package.json { "private": true, "scripts": { "dev": "node_modules/nuxt/bin/nuxt.js -c client/nuxt.config.js", "build": "node_modules/nuxt/bin/nuxt.js build -c

Tabulator + Nuxt.js: How to use axios in callbacks?

风流意气都作罢 提交于 2021-01-29 14:46:47
问题 I try to add Tabulator in my Nuxt.js project. I have done the next component: <template> <div ref="table"></div> </template> <script> let Tabulator = require("tabulator-tables") import 'tabulator-tables/dist/css/tabulator_simple.min.css' let saveIcon = function(cell, formatterParams, onRendered) { return "<img src='/icons/save.png'>"; } export default { data() { return { tabulator: null, tableData: [ { id: 1, username: 'user', email: 'email@email.ru', activationCode:'1243412-123413-4134',

Cannot import bootstrap in nuxt vue component [duplicate]

爱⌒轻易说出口 提交于 2021-01-29 13:27:49
问题 This question already has answers here : “Uncaught SyntaxError: Cannot use import statement outside a module” when importing ECMAScript 6 (12 answers) Closed 10 months ago . I can't import bootstrap in any vue component (using latest nuxtjs). I get : My (simple) component is : <template> <h1>Empty index page</h1> </template> <script> import Modal from 'bootstrap/js/src/modal' export default {} </script> <style></style> I am really stuck. Do you have any idea or suggestion ? 回答1: You should