nuxt.js

How to submit a form in Vue, redirect to a new route and pass the parameters?

夙愿已清 提交于 2019-12-04 19:46:47
问题 I am using Nuxt and Vue and I am trying to submit a form, redirect the user to a new route including the submitted params, send an API request to get some data and then render that data. I achieved this by simply setting the form action to the new path and manually adding all the URL parameters to the API request. First I create a simple form with the route /search . <form action="/search"> <input type="text" name="foobar"> <button type="submit">Submit</button> </form> When submitting the

Deploy Nuxt.js to Google App Engine Return 502 Bad Gateway

允我心安 提交于 2019-12-04 19:18:25
Hi is there anyone who has tried to deploy nuxt app to Google App Engine. I have tried from nuxt regular and express template, it shows 502 Bad Gateway. I don't modify anything from create-nuxt-app command. My app.yaml file contains runtime: nodejs env: flex Is there anything wrong with my setup or maybe there are some additional setup I have to do? Here is my package.json { "name": "nuxt-pwa-vuetify-starter", "version": "1.0.0", "description": "Nuxt.js + PWA + Vuetify.js starter project", "author": "Jefry Dewangga <jefrydco@gmail.com>", "private": true, "homepage": "https://github.com

I can't use third party components in Nuxt.js/vue.js

纵然是瞬间 提交于 2019-12-04 17:10:24
I attempt use this library for my Nuxt project: getting-started I tried do how to written in docs, but in all variants get an error for exmaple: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option. what i tried: <template> <div class="div-wrapper"> <h1>grge</h1> <div id="typeahead"><typeahead :data="USstate" placeholder="USA states"> </typeahead></div> </div> </template> <style lang="less"> .div-wrapper { background: #f4f4f4; padding: 95px 15px 50px 15px; } </style> <script> import Vue from 'vue'; export default {

“document is not defined” in Nuxt.js

心已入冬 提交于 2019-12-04 09:52:16
I am trying to use Choices.js within a Vue component. The component compiles successfully, but then an error is triggered: [vue-router] Failed to resolve async component default: ReferenceError: document is not defined In the browser I see: ReferenceError document is not defined I think this has something to do with the SSR in Nuxt.js? I only need Choices.js to run on the client, because it's a client only aspect I guess. nuxt.config.js build: { vendor: ['choices.js'] } AppCountrySelect.vue <script> import Choices from 'choices.js' export default { name: 'CountrySelect', created () { console

Can anyone help implementing Nuxt.js Google Tag Manager?

半世苍凉 提交于 2019-12-04 09:25:34
问题 Hey i've built a Nuxt app and am having trouble with the package @nuxtjs/google-tag-manager package. Found below. The documentation is pretty light and I haven't found many example implementations out there. In my nuxt.config.js I have the following set. ['@nuxtjs/google-tag-manager', { id: process.env.GTM_ID, layer: 'dataLayer', pageTracking: true }], ..but unfortunately am not getting any Page Views in Google Tag Manager Does anyone have any ideas or experience in how to best implement GTM

How to submit a form in Vue, redirect to a new route and pass the parameters?

允我心安 提交于 2019-12-03 12:08:44
I am using Nuxt and Vue and I am trying to submit a form, redirect the user to a new route including the submitted params, send an API request to get some data and then render that data. I achieved this by simply setting the form action to the new path and manually adding all the URL parameters to the API request. First I create a simple form with the route /search . <form action="/search"> <input type="text" name="foobar"> <button type="submit">Submit</button> </form> When submitting the form the user leaves the current page and gets redirected to the new page. The URL would now look like

Vue.js: Nuxt error handling

时光毁灭记忆、已成空白 提交于 2019-12-03 10:05:55
Struggling a bit to set up error handling with vuex. There seems to be quite a few ways to do so and little documentation on proper error handling. I've been experimenting with four alternatives, though I haven't found a satisfying solution yet. Alternative 1 - Catching and processing errors on component in pages/login.vue: export default { methods: { onLogin() { this.$store.dispatch('auth/login', { email: this.email, password: this.password, }).then(() => { this.$router.push('/home'); }).catch((error) { // handle error in component }); }, }, } in store/auth.js: export const actions = { login(

Best way to config Global Headers for Get, Post, Patch in VueJS

廉价感情. 提交于 2019-12-03 08:43:00
I'm new with VueJs, I'm finding best way to config Global Headers for Get, Post, Patch in VueJS, which is easy to use and strong security . In the current I just write it in export default {} for every components and it's very bad I know. So I ask you guys to help. Fixed Thanks to @Hardik Satasiya ~/plugins/axios.js Every Components: import axios from 'axios' var api = axios.create({ baseURL: 'http://localhost:8000/api/v1/', headers: {'Authorization': 'JWT ' + store.state.token} }) export default api Issues: Can't tranmit store in to axios.create, so store is not defined Yes its good idea to

How to watch on Route changes with Nuxt and asyncData

寵の児 提交于 2019-12-03 08:25:27
Hi everybody i'm trying to watch on route changes in my nuxt js app. Here my middleware: export default function ({ route }) { return route; but i don't know what to write here } index.vue File middleware: [routeReact] i'm trying to write this: app.context.route = route but it says to me that app.context doesn't exist Here's the point of my question i'm trying to update my data that gets from my api with axios on page if route changing like this this the page i'm clicking link to next page : but when i'm route to next page, nothing happens all data is the same: here my asyncData code:

Where to store common component methods in #NUXT.JS

为君一笑 提交于 2019-12-03 05:41:56
问题 Actually i want to know where to store common components methods in #NUXT.JS. things which i have tried. --> Storing common code in middleware (its use-less) because according to my knowledge middleware is only capable of handling request and response to server. methods: { // states methods. SwitchManager: function (__dataContainer, __key, __value) { // stand alone debugger for this module. let debug = __debug('computed:_3levelSwitch') // debug showing function loaded. debug('(h1:sizeCheck)