vuejs3

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

Using Bootstrap 5 with Vue 3

♀尐吖头ヾ 提交于 2021-01-27 16:29:04
问题 I want to use Bootstrap 5 with Vue 3. As Bootstrap 5 uses vanilla JS (no JQuery), can I use Bootstrap 5 directly in a Vue 3 project (without using Bootstrap-Vue)? Can someone guide me how to use Bootstrap 5 with Vue 3? 回答1: Install bootstrap as you would any other JS module in the Vue project using npm install or by adding it to the package.json . Then, the simplest way to use Bootstrap components is via the data-bs- attributes. For example here's the Bootstrap Collapse component... <button

Vue 3 The template root requires exactly one element.eslint-plugin-vue

末鹿安然 提交于 2021-01-27 14:13:56
问题 After scafolding a Vue 3 project I noticed a error in my App.vue. A functional component that renders the matched component for the given path. Components rendered in can also contain its own , which will render components for nested paths. API Reference [vue/no-multiple-template-root] The template root requires exactly one element.eslint-plugin-vue I tried putting "vue/no-multiple-template-root": 0 in my .eslintrc.js But the error remains. How can I get rid of the error? Since in Vue 3 you

vue 3 emit warning “ Extraneous non-emits event listeners”

我的未来我决定 提交于 2021-01-27 04:16:10
问题 I am trying to emit data from child to parent using the composition API I get the following warning. [Vue warn]: Extraneous non-emits event listeners (updatedcount) were passed to component but could not be automatically inherited because component renders fragment or text root nodes. If the listener is intended to be a component custom event listener only, declare it using the "emits" option.at <HelloWorld onUpdatedcount=fn > at childcomponent.vue <template> <h1>{{ store.count }}</h1>

Vue 3 - Emit event from child component within a slot

爱⌒轻易说出口 提交于 2021-01-24 11:35:07
问题 I'm looking at upgrading to v3 and was disappointed to see inline-template has been removed. Therefore I'm trying to convert to use a scoped slot instead. I have defined the following list component: <template> <slot :items="filteredItems" :page="page" :totalPages="totalPages" :onPageChanged="onPageChanged"></slot> </template> <script> export default { props: { items: { type: Array }, initialPage: { type: Number, default: 1, }, pageSize: { type: Number, default: 10 } }, beforeCreate() { this

Vue 3 how to get information about $children

时光怂恿深爱的人放手 提交于 2021-01-23 05:02:37
问题 This my old code with VUE 2 in Tabs component: created() { this.tabs = this.$children; } Tabs: <Tabs> <Tab title="tab title"> .... </Tab> <Tab title="tab title"> .... </Tab> </Tabs> VUE 3: How can I get some information about childrens in Tabs component, using composition API? Get length, iterate over them, and create tabs header, ...etc? Any ideas? (using composition API) 回答1: To someone wanting whole code: Tabs.vue <template> <div> <div class="tabs"> <ul> <li v-for="tab in tabs" :class="{

Vue 3 how to get information about $children

大城市里の小女人 提交于 2021-01-23 04:59:29
问题 This my old code with VUE 2 in Tabs component: created() { this.tabs = this.$children; } Tabs: <Tabs> <Tab title="tab title"> .... </Tab> <Tab title="tab title"> .... </Tab> </Tabs> VUE 3: How can I get some information about childrens in Tabs component, using composition API? Get length, iterate over them, and create tabs header, ...etc? Any ideas? (using composition API) 回答1: To someone wanting whole code: Tabs.vue <template> <div> <div class="tabs"> <ul> <li v-for="tab in tabs" :class="{

How to use Vue.prototype or global variable in Vue 3?

╄→尐↘猪︶ㄣ 提交于 2021-01-20 04:47:58
问题 Like the title, I want to add Axios into Vue prototype. So when I want to use it, I can use it like this.$axios instead of importing it every time. CODE: //plugins/axios.ts import axios from 'axios' import router from '../router/index' const errorHandle = (): void => {}; const instance = axios.create({ // baseURL: process.env.NODE_ENV == 'development' ? '' : '' baseURL: 'http://localhost:3000', timeout: 1000 * 12 }); instance.defaults.headers.post['Content-Type'] = 'application/x-www-form

How to use Vue.prototype or global variable in Vue 3?

回眸只為那壹抹淺笑 提交于 2021-01-20 04:47:35
问题 Like the title, I want to add Axios into Vue prototype. So when I want to use it, I can use it like this.$axios instead of importing it every time. CODE: //plugins/axios.ts import axios from 'axios' import router from '../router/index' const errorHandle = (): void => {}; const instance = axios.create({ // baseURL: process.env.NODE_ENV == 'development' ? '' : '' baseURL: 'http://localhost:3000', timeout: 1000 * 12 }); instance.defaults.headers.post['Content-Type'] = 'application/x-www-form