Vue.js

How to get http refere in vuejs?

元气小坏坏 提交于 2021-01-27 18:24:56
问题 I would like to get from which page a user came from in my page. Currently, I would like to get this info in my created() or mounted() pages. Using this.$router or this.$route but none of them contain this info. I know in the navigation guards, we can use this : router.beforeEach((to, from, next) => { }) to know where the page is comming from, but I don't want to use router.beforeEach because that is in found inside my main.js but where I want to get the referer is in my components page,

Deploy Vue to GitHub Pages. Error with vue-router

泄露秘密 提交于 2021-01-27 18:10:48
问题 I was experiencing some trouble while deploying a Vue application build with vue-cli v3.0. to GitHub Pages. I'm using subtree to send the dist folder only to gh-pages branch. First the problem was that the assets where not found but I fixed it using baseUrl on vue.config.js . Now the problem is that the #app element is empty. I found out that if I don't use vue-router (render the view direct instead of using <router-view/> ) the app works fine with GitHub pages. I believe there is some issue

Deploy Vue to GitHub Pages. Error with vue-router

北战南征 提交于 2021-01-27 17:58:23
问题 I was experiencing some trouble while deploying a Vue application build with vue-cli v3.0. to GitHub Pages. I'm using subtree to send the dist folder only to gh-pages branch. First the problem was that the assets where not found but I fixed it using baseUrl on vue.config.js . Now the problem is that the #app element is empty. I found out that if I don't use vue-router (render the view direct instead of using <router-view/> ) the app works fine with GitHub pages. I believe there is some issue

How to declare TypeScript type interface for custom meta fields in Vue Router v4?

[亡魂溺海] 提交于 2021-01-27 16:44:14
问题 With Vue Router version 4 , which is currently in beta.11 in vue-router-next repo, there is a documentation page about how to define meta fields custom type interface with TypeScript . declare module 'vue-router' { interface RouteMeta { // is optional isAdmin?: boolean // must be declared by every route requiresAuth: boolean } } To be placed along the Vue shim module declaration. Mine is looking like: declare module '*.vue' { import { defineComponent } from 'vue'; const component: ReturnType

How to declare TypeScript type interface for custom meta fields in Vue Router v4?

本秂侑毒 提交于 2021-01-27 16:44:08
问题 With Vue Router version 4 , which is currently in beta.11 in vue-router-next repo, there is a documentation page about how to define meta fields custom type interface with TypeScript . declare module 'vue-router' { interface RouteMeta { // is optional isAdmin?: boolean // must be declared by every route requiresAuth: boolean } } To be placed along the Vue shim module declaration. Mine is looking like: declare module '*.vue' { import { defineComponent } from 'vue'; const component: ReturnType

How to declare TypeScript type interface for custom meta fields in Vue Router v4?

懵懂的女人 提交于 2021-01-27 16:40:37
问题 With Vue Router version 4 , which is currently in beta.11 in vue-router-next repo, there is a documentation page about how to define meta fields custom type interface with TypeScript . declare module 'vue-router' { interface RouteMeta { // is optional isAdmin?: boolean // must be declared by every route requiresAuth: boolean } } To be placed along the Vue shim module declaration. Mine is looking like: declare module '*.vue' { import { defineComponent } from 'vue'; const component: ReturnType

VueJS in IE 11 - template wrapper for <tr> not working, works in Edge and Chrome

杀马特。学长 韩版系。学妹 提交于 2021-01-27 16:38:00
问题 This is using Vue 2.5.16 in IE 11. Assume a dataset array in app.data, the following works fine in Chrome (and the code is simplified): ... <tbody> <template v-for="(datarow, index) in dataset"> <tr><td> {{ datarow }} {{ index }} </td></tr> <tr v-if="!(index % 50)"><td> -repeating header row- </td></tr> </template> </tbody> ... However, in IE 11, it does not work and furthermore there is no line and character number in console error (took me some time to figure out). It just says in red:

VueJS in IE 11 - template wrapper for <tr> not working, works in Edge and Chrome

こ雲淡風輕ζ 提交于 2021-01-27 16:34:15
问题 This is using Vue 2.5.16 in IE 11. Assume a dataset array in app.data, the following works fine in Chrome (and the code is simplified): ... <tbody> <template v-for="(datarow, index) in dataset"> <tr><td> {{ datarow }} {{ index }} </td></tr> <tr v-if="!(index % 50)"><td> -repeating header row- </td></tr> </template> </tbody> ... However, in IE 11, it does not work and furthermore there is no line and character number in console error (took me some time to figure out). It just says in red:

Why does position of x-template section matter for vue templates to work with data?

余生长醉 提交于 2021-01-27 14:56:36
问题 I have an vue app and a global component. Both have a data property. For the component I use the x-template way to keep my html code together. I have encountered a strange error where the data was not available in the component, although the component was rendered properly when I didn't access the data in the component. Here comes the HTML: <h1>Hello</h1> <div id='app'> <p>Here is the app: {{message}}</p> <my-component></my-component> <script type="text/x-template" id="template"> <div> <p

How can I access data in asyncData with Nuxt

柔情痞子 提交于 2021-01-27 13:54:19
问题 I'm attempting to build a server-side sortable table with Nuxt, and I'd like to be able to specify the default sort column and direction in my Vue data , and access that in my asyncData function. Something like this: <script> export default { async asyncData ({ $axios, params }) { const things = await $axios.$get(`/api/things`, { params: { sort_column: this.sortColumn, sort_ascending: this.sortAscending, } }); return { things }; }, data () { return { sortColumn: 'created_at', sortAscending: