nuxt.js

Can anyone help implementing Nuxt.js Google Tag Manager?

房东的猫 提交于 2019-12-03 03:11:25
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 or what has worked for them? Thanks in advance I had a look at the package, inside modules/packages

Difference between Asyncdata vs Fetch

只谈情不闲聊 提交于 2019-12-03 01:32:07
What is the exact difference between fetch and async data. The official documentation says the following: asyncData You may want to fetch data and render it on the server-side. Nuxt.js adds an asyncData method that lets you handle async operations before setting the component data. asyncData is called every time before loading the component (only for page components). It can be called from the server-side or before navigating to the corresponding route. This method receives the context object as the first argument, you can use it to fetch some data and return the component data. Fetch The

Nuxt.js - force trailing slash at the end of all urls

安稳与你 提交于 2019-12-02 14:06:51
问题 I'm looking for a way to make sure that all of my urls end with a trailing slash (so first check if there is already a trailing slash at the end, and if not add one). I have tried with nuxt-redirect-module, and it works adding the slash but then it leads to an infinite redirect redirect: [ { from: '^(.*)$', to: (from, req) => { let trailingUrl = req.url.endsWith('/') ? req.url : req.url + '/' return trailingUrl } } ] Any insight will be welcome. Thanks! 回答1: You can try to match only those

Remove class nuxt-link-exact-active or giving style css on it

为君一笑 提交于 2019-12-02 12:11:57
i want to give class active in each href based on current link. but now i have problem about remove class nuxt-link-exact-active or giving style on it, i my current template already has style .mainNav .nav-item.active .nav-link so all i need to do remove class nuxt-link-exact-active giving style nuxt-link-exact-active but i did number 2 but still not working this is my demo https://codesandbox.io/s/m3rpmrk0xj 来源: https://stackoverflow.com/questions/54029794/remove-class-nuxt-link-exact-active-or-giving-style-css-on-it

How to mock a Vuex store in VueJS test-utils parentComponent

耗尽温柔 提交于 2019-12-02 09:33:55
I'm using Jest with vue-test-utils trying to test if a child component reacts to an $emit event in the parent component. VueJS test-utils library provides a parentComponent option to be passed when mounting/shallow mounting the component. Everything is working fine except that even though I instantiate the component with a mocked Vuex store, the parent component throws a TypeError: Cannot read property 'state' of undefined on a this.$store.state.something.here piece of code in the parent component. How can I mock the Vuex store there? The component mount looks like this: const wrapper =

SyntaxError: Unexpected token export when using lodash with Nuxt

北战南征 提交于 2019-12-02 07:17:14
问题 Here is my repo with live demo https://github.com/alechance/nuxt-lodash. I'm using Nuxt with Vuetify + lodash-es, when running npm run dev and reload my page I got a SyntaxError: Unexpected token export with export default isArray; 回答1: Imported files of lodash-es library are not transpiled by babel . To fix that, Nuxt.js provides option to manually specify files that should be transpiled via transpile option. Add following code to build section of nuxt.config.js : build: { transpile: [

SyntaxError: Unexpected token export when using lodash with Nuxt

南笙酒味 提交于 2019-12-02 05:19:44
Here is my repo with live demo https://github.com/alechance/nuxt-lodash . I'm using Nuxt with Vuetify + lodash-es, when running npm run dev and reload my page I got a SyntaxError: Unexpected token export with export default isArray; Imported files of lodash-es library are not transpiled by babel . To fix that, Nuxt.js provides option to manually specify files that should be transpiled via transpile option. Add following code to build section of nuxt.config.js : build: { transpile: [ 'lodash-es' ], // Other build options } 来源: https://stackoverflow.com/questions/53081769/syntaxerror-unexpected

Conditional stylesheet in Nuxt

▼魔方 西西 提交于 2019-12-01 13:53:45
My CSS is not rendering well in Internet explorer even after using IE prefixes. So I want to try conditional stylesheet, but I'm not sure how to go about that in Nuxt In Nuxt the best bet is to use CSS Conditional stylesheet in nuxt.config.js or use it in the default.vue template, but that does not fit in there since conditional stylesheet is normally applied in the head tag. <!--[if IE]> <link rel="stylesheet" type="text/css" href="all-ie-only.css" /> <![endif]--> This a typical example of what I want to try. If I can get help on how to format it so it can be used in the nuxt.config.js or in

How to run NUXT (npm run dev) with HTTPS in localhost?

﹥>﹥吖頭↗ 提交于 2019-12-01 06:29:40
问题 EDIT: Updated the text in general to keep it shorter and more concise. I am trying to configure HTTPS when I run npm run dev so I can test MediaStream and alike locally (for which browsers require me to provide HTTPS). I am trying to configure it through nuxt.config.js but without any success. Here is my nuxt.config.js file: import fs from "fs"; import pkg from "./package"; export default { mode: "spa", /* ** Headers of the page */ head: { title: pkg.name, meta: [ { charset: "utf-8" }, { name

How to use Facebook SDK with Nuxt.js?

风流意气都作罢 提交于 2019-12-01 05:14:29
You can see my code. npm install vue init nuxt/koa my-project (koa@2) pages |- login.vue <script> export default { name: 'login', method: { login () { let vm = this FB.login(function (response) { vm.statusChangeCallback(response) }, {scope: 'publish_actions'}) } }, mounted () { console.log('mounted') let vm = this window.fbAsyncInit = () => { FB.init({ appId: 'my-facebook-app-id', cookie: true, xfbml: true, version: 'v2.8' }) FB.getLoginStatus(function (response) { vm.statusChangeCallback(response) }) } (function(d, s, id){ var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id))