Can´t import route link component in Vue - vue.js

I try to create routes with vue router. The App.js code looks
JS
require("./bootstrap");
import Swal from "sweetalert2";
import VueI18n from 'vue-i18n'
import VueRouter from 'vue-router'
import Vuetify from "vuetify";
import es from "vuetify/es5/locale/es";
import en from "vuetify/es5/locale/en";
import "#mdi/font/css/materialdesignicons.css";
import ContadorComponent from "./components/ContenedorComponent.vue";
import GatewayComponent from "./components/GatewayComponent.vue";
const routes = [{
path: '/contador',
component: ContadorComponent
},
{
path: '/gateway',
component: GatewayComponent
}
]
window.Vue = require("vue");
Vue.use(Vuetify, VueRouter, VueI18n, Swal);
Vue.component(
"drawer-component",
require("./components/DrawerComponent.vue").default,
/* methods: {
changeLocale (lang) {
this.$vuetify.lang.current = lang
},
},*/
);
export default new Vuetify({
icons: {
iconfont: "mdi"
},
lang: {
locales: {
es,
en
},
current: "es"
}
});
const router = new VueRouter({
routes
})
new Vue({
vuetify: new Vuetify(),
router,
}).$mount("#app");
VUE (Vuetify)
<template>
<v-app id="app">
<v-navigation-drawer v-model="drawer" app permanent expand-on-hover>
<v-list dense>
<v-list-item link>
<v-list-item-action>
<v-icon>mdi-home</v-icon>
</v-list-item-action>
<v-list-item-content>
<v-list-item-title>Principal</v-list-item-title>
</v-list-item-content>
</v-list-item>
<v-list-group prepend-icon="mdi-directions-fork">
<template v-slot:activator>
<v-list-item-title>Gateways</v-list-item-title>
</template>
<v-list-item link>
<v-list-item-icon>
<v-icon>mdi-format-list-bulleted</v-icon>
</v-list-item-icon>
<v-list-item-title>Listado</v-list-item-title>
</v-list-item>
</v-list-group>
<v-list-group prepend-icon="mdi-speedometer">
<template v-slot:activator>
<v-list-item-title>Contadores</v-list-item-title>
</template>
<v-list-item link>
<v-list-item-icon>
<v-icon>mdi-format-list-bulleted</v-icon>
</v-list-item-icon>
<v-list-item-title>Listado</v-list-item-title>
</v-list-item>
</v-list-group>
</v-list>
</v-navigation-drawer>
<v-app-bar app elevate-on-scroll dark>
<v-toolbar-title class="d-sm-flex">LoRaWAN</v-toolbar-title>
<v-divider class="mx-4 d-sm-flex" inset vertical></v-divider>
<v-toolbar-items class="d-sm-flex">
<v-col class="d-flex" cols="3" sm="6">
<v-select :items="items" label="Instalaciones" dense outlined></v-select>
</v-col>
<v-col class="d-flex" cols="3" sm="6">
<v-select :items="items" label="Agrupaciones" dense outlined></v-select>
</v-col>
</v-toolbar-items>
<v-spacer></v-spacer>
<v-menu open-on-hover right bottom>
<template v-slot:activator="{ on }">
<v-btn icon v-on="on">
<v-icon>mdi-account-circle</v-icon>
</v-btn>
</template>
<v-list>
<v-list-item link>
<v-list-item-title>
<v-icon>mdi-exit-run</v-icon>Salir
</v-list-item-title>
</v-list-item>
</v-list>
</v-menu>
</v-app-bar>
<v-content>
<v-container class="fill-height" fluid>
<v-row align="center" justify="center">
<router-link to="/contador">Go to Contadores</router-link>|
<router-link to="/gateway">Go to Gateway</router-link>
</v-row>
</v-container>
<router-view></router-view>
</v-content>
<v-footer dark app>
<span class="white--text">{{ new Date().getFullYear() }}</span>
<span class="white--text text-right">Versión 2.0</span>
</v-footer>
</v-app>
</template>
<script>
export default {
props: {
source: String
},
data: () => ({
items: ["Foo", "Bar", "Fizz", "Buzz"],
drawer: null
})
};
</script>
The problem: Returns Unknown custom element: router-link I import VueRouter so i don´t know what´s fails. Anybody see the error?

Vue.use argument is {Object | Function} plugin.
You are trying to install multiple Vue plugins at once.
Instead of:
Vue.use(Vuetify, VueRouter, VueI18n, Swal);
Do:
Vue.use(Vuetify);
Vue.use(VueRouter);
Vue.use(VueI18n);
Vue.use(Swal);

Related

Vue.js “Maximum call stack size exceeded” error. Use dialog for child and passing data from parent to child failing

I am working on Vuetify.js and I am a newbie in Vue, I referred this document Vuetify Dialogs for creating dialog and solution of Matheus Dal'Pizzol from this link Open a Vuetify dialog from a component template in VueJS
to separate it to the component.
The result I have child component as dialog as below
Parent
<template>
<v-container fluid>
<v-row dense>
<v-col cols="12">
<v-btn large color="success">Add product</v-btn>
</v-col>
<v-col cols="3" v-for="product in products" :key="product.id">
<v-card class="mx-auto" outlined>
<v-list-item three-line>
<v-list-item-content>
<v-list-item-title class="headline mb-1">{{product.name}}</v-list-item-title>
<v-list-item-subtitle>{{product.title}}</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>
<v-card-actions>
<v-btn dark color="cyan" #click.stop="showScheduleForm = true">
<v-icon dark>mdi-television</v-icon>
</v-btn>
<v-btn color="primary">Detail</v-btn>
</v-card-actions>
</v-card>
<modal-detail v-model="showScheduleForm" :productDetailInfo="product"></modal-detail>
</v-col>
</v-row>
</v-container>
</template>
<script>
import axios from "axios";
import ModalDetail from "./ModalDetail.vue";
export default {
name: "HelloWorld",
components: {
ModalDetail
},
data: function() {
return {
showScheduleForm: false,
products: [],
errors: []
};
},
...
Child
<template>
<v-dialog v-model="show" max-width="500" v-if="Object.keys(productDetailInfo).length !== 0">
<v-card>
<v-card-title class="headline grey lighten-2" primary-title>{{ productDetailInfo.name }}</v-card-title>
<v-card-text>{{ productDetailInfo.title }}</v-card-text>
<v-divider></v-divider>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="green darken-1" text #click.stop="show = false">Close</v-btn>
<v-btn color="primary">Detail</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</template>
<script>
export default {
name: "ModalDetail",
props: {
productDetailInfo: {
type: Object
},
value: Boolean
},
computed: {
show: {
get() {
return this.value;
},
set(value) {
this.$emit("input", value);
}
}
}
};
</script>
However, I am getting an exception when I click icon-button "Maximum call stack size exceeded".
It seems there is a continuous loop happening.
Please help! Am I missing something?
That's because your v-dialog is in v-for loop, it's common problem. To workaround it add :retain-focus="false" as a prop to your v-dialog
Maybe try to use v-on:click.stop instead of #click.stop in the v-btn as it's the recommended syntax for Vue 2.x.

v-navigation-drawer takes up the entire row

my v-navigation-drawer takes up the entire row, so the content goes underneath the drawer. I was trying to research online but didn't find anything about it. I am very new to Vuetify. Please help. If you look at the screenshot the Dashboard must be next to drawer but it goes underneath. I have two components Navbar and Drawer. I render them inside of my App.vue. I attached the code below.
App.vue
<template>
<v-app>
<navbar/>
<drawer/>
<v-content>
<h1>Dashboard</h1>
</v-content>
</v-app>
</template>
<script>
import Drawer from './components/Drawer';
import Navbar from './components/Navbar';
export default {
name: 'App',
components: {
Drawer,
Navbar,
},
data: () => ({
}),
method:() => ({})
};
</script>
<style>
</style>
Navbar.vue
<template>
<div>
<nav>
<v-toolbar class="cyan lighten-1" dark prominent height="65">
<v-toolbar-title class="text-uppercase gray--text">
<span class="font-weight-light">Stock</span>
<span>Dashboard</span>
</v-toolbar-title>
<v-spacer></v-spacer>
<v-btn text color="black">
<span>Log Out</span>
<v-icon right>exit_to_app</v-icon>
</v-btn>
</v-toolbar>
</nav>
</div>
</template>
<script>
export default {
data(){
return {
}
}
}
</script>
<style>
</style>
Drawer.vue
<template>
<v-navigation-drawer id="app-drawer" class="cyan lighten-1" dark permanent>
<v-list>
<v-list-tile avatar>
<v-list-tile-avatar color="white">
<v-img :src="require('../assets/bull.svg')" height="70" contain class="cyan darken-5"></v-img>
</v-list-tile-avatar>
</v-list-tile>
<v-list-item
v-for="item in items"
:key="item.title"
link
>
<v-list-item-icon>
<v-icon>{{ item.icon }}</v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title>{{ item.title }}</v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list>
<template v-slot:append>
<div class="pa-2">
<v-btn block>Logout</v-btn>
</div>
</template>
</v-navigation-drawer>
</template>
<script>
export default {
data () {
return {
items: [
{ title: 'Dashboard', icon: 'dashboard' },
{ title: 'Account', icon: 'account_box' },
{ title: 'Admin', icon: 'gavel' },
],
}
},
}
</script>
<style>
</style>
Use "app" in v-navigation-drawer like so :
<v-navigation-drawer id="app-drawer" class="cyan lighten-1" dark permanent app>
Further take a look at https://vuetifyjs.com/en/components/navigation-drawers API and use v-app-bar instead of v-toolbar for the main toolbar of your page.

How can I use bottom navigation and navigation drawers together? v-app doesn't work

I am new to vuetify and vue, I want to create a layout in which the users with sm or smaller screens will use the bottom-navigation component and the users with md or higher will use the navigation drawers.
I am using the v-app component, that according to the docs "help bootstrap your application with the proper sizing around component" and "These (components) can be mixed and matched and only one of each particular component should exist at any time."
<template>
<v-app>
<v-navigation-drawer app>
<v-list rounded>
<v-subheader>REPORTS</v-subheader>
<v-list-item-group v-model="item" color="primary">
<v-list-item v-for="(item, i) in items" :key="i">
<v-list-item-icon>
<v-icon v-text="item.icon"></v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title v-text="item.text"></v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list-item-group>
</v-list>
</v-navigation-drawer>
<v-app-bar app>
<v-toolbar-title class="headline text-uppercase">
<span>Vuetify</span>
<span class="font-weight-light">MATERIAL DESIGN</span>
</v-toolbar-title>
<v-spacer></v-spacer>
<v-btn text href="https://github.com/vuetifyjs/vuetify/releases/latest" target="_blank">
<span class="mr-2">Latest Release</span>
</v-btn>
</v-app-bar>
<v-content fluid>
<HelloWorld />
</v-content>
<v-bottom-navigation app>
<v-btn value="recent">
<span>Recent</span>
<v-icon>history</v-icon>
</v-btn>
<v-btn value="favorites">
<span>Favorites</span>
<v-icon>favorite</v-icon>
</v-btn>
<v-btn value="nearby">
<span>Nearby</span>
<v-icon>place</v-icon>
</v-btn>
</v-bottom-navigation>
</v-app>
</template>
<script lang="ts">
import Vue from "vue";
import HelloWorld from "./components/HelloWorld.vue";
export default Vue.extend({
name: "App",
components: {
HelloWorld
},
data: () => ({
item: 1,
items: [
{ text: "Real-Time", icon: "mdi-clock" },
{ text: "Audience", icon: "mdi-account" },
{ text: "Conversions", icon: "mdi-flag" }
]
})
});
</script>
So the documentation it's perhaps a bit unclear from the text.
It's up to you to display them as you see fit. But you should for example not have two v-app-bars visible at the same time.
So here is the solution:
<template>
<v-app>
<v-navigation-drawer app v-model="$vuetify.breakpoint.mdAndUp" stateless class="hidden-sm-and-down">
<v-list rounded>
<v-subheader>REPORTS</v-subheader>
<v-list-item-group v-model="item" color="primary">
<v-list-item v-for="(item, i) in items" :key="i">
<v-list-item-icon>
<v-icon v-text="item.icon"></v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title v-text="item.text"></v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list-item-group>
</v-list>
</v-navigation-drawer>
<v-app-bar app class="hidden-sm-and-down">
<v-toolbar-title class="headline text-uppercase">
<span>Vuetify</span>
<span class="font-weight-light">MATERIAL DESIGN</span>
</v-toolbar-title>
<v-spacer></v-spacer>
<v-btn text href="https://github.com/vuetifyjs/vuetify/releases/latest" target="_blank">
<span class="mr-2">Latest Release</span>
</v-btn>
</v-app-bar>
<v-content fluid>
<HelloWorld />
</v-content>
<v-bottom-navigation app class="d-flex d-md-none">
<v-btn value="recent">
<span>Recent</span>
<v-icon>history</v-icon>
</v-btn>
<v-btn value="favorites">
<span>Favorites</span>
<v-icon>favorite</v-icon>
</v-btn>
<v-btn value="nearby">
<span>Nearby</span>
<v-icon>place</v-icon>
</v-btn>
</v-bottom-navigation>
</v-app>
</template>
<script lang="ts">
import Vue from "vue";
import HelloWorld from "./components/HelloWorld.vue";
export default Vue.extend({
name: "App",
components: {
HelloWorld
},
data: () => ({
item: 1,
items: [
{ text: "Real-Time", icon: "mdi-clock" },
{ text: "Audience", icon: "mdi-account" },
{ text: "Conversions", icon: "mdi-flag" }
]
})
});
</script>

Vuex(store js) doesn't update the computed property only if I refresh the page

Hi I am making a get call in store js and I pass it as computed property in Movie.vue, when I refresh the page I get the real value if I change the view or I go back to the index the value will not change will stay the same.Every time I need to refresh the page in order to access a new value from store js.
<template>
<div >
<Navbar />
<v-parallax
dark
src="https://cdn.vuetifyjs.com/images/backgrounds/vbanner.jpg"
>
<v-layout
align-center
column
justify-center
>
<h1 class="display-2 font-weight-thin mb-3">{{film_title}}</h1>
<h4 class="subheading">{{film_tagline}}</h4>
</v-layout>
</v-parallax>
<v-container fluid>
<v-layout row>
<v-flex xs10 sm6 md4 lg3 offset-sm1 style="position:absolute; top:350px;">
<v-card>
<v-img
:src="'https://image.tmdb.org/t/p/original' + film_poster_path"
aspect-ratio=".75" style="background-image-width:300px;"
></v-img>
<v-card-title primary-title>
<div>
<h5 xs12 sm6 >
<v-chip color="orange" text-color="white" v-if="film_genres_1">
{{film_genres_1}}
<v-icon right>star</v-icon>
</v-chip>
<v-chip color="primary" text-color="white" v-if="film_genres_2">
{{film_genres_2}}
<v-icon right>star</v-icon>
</v-chip>
<v-chip color="green" text-color="white" v-if="film_genres_3">
{{film_genres_3}}
<v-icon right>star</v-icon>
</v-chip>
<v-chip color="red" text-color="white" v-if="film_genres_4">
{{film_genres_4}}
<v-icon right>star</v-icon>
</v-chip>
<v-chip label color="pink" text-color="white" v-if="film_production">
<v-icon left>label</v-icon>Produce by: {{film_production}}
</v-chip>
<v-chip label color="secondary" text-color="white" v-if="film_release_date">
<v-icon left>label</v-icon>Release date: {{film_release_date}}
</v-chip>
<v-chip color="primary" text-color="white">Run time: {{film_runtime}} minutes</v-chip>
</h5>
</div>
</v-card-title>
</v-card>
</v-flex>
<v-flex xs7 offset-xs5>
<v-expansion-panel
expand
>
<v-expansion-panel-content
v-for="(item, i) in 1"
:key="i"
>
<template v-slot:header>
<div>Overview</div>
</template>
<v-card>
<v-card-text class="grey lighten-3">{{film_overview}}</v-card-text>
</v-card>
</v-expansion-panel-content>
</v-expansion-panel>
<vue-plyr>
<div class="plyr__video-embed" :key="$route.fullPath">
<iframe
:src="'https://www.youtube.com/watch?v=' +video_key"
allowfullscreen allowtransparency allow="autoplay">
</iframe>
</div>
</vue-plyr>
</v-flex>
<div class="loading" v-if="loading"><fingerprint-spinner/></div>
</v-layout>
</v-container>
</div>
</template>
<script>
import Navbar from '../components/Navbar'
import axios from "axios"
export default {
components:{
Navbar,
},
created() {
this.$store.dispatch("fetchData");
},
computed:{
video_key() {
return this.$store.state.video_key
}},
data () {
return {
loading:true,
componentKey: 0,
movie_key:null,
fun:true,
film_poster_path:null,
film_title:null,
film_tagline:null,
film_overview:null,
film_genres:null,
film_genres_1:null,
film_genres_2:null,
film_genres_3:null,
film_genres_4:null,
film_production:null,
film_release_date:null,
film_runtime:null,
film_key:null,
// video_key:null,
m_id:this.$route.params.m_id
}
},
mounted() {
// axios
// .get(`https://api.themoviedb.org/3/movie/${this.m_id}/videos?api_key=&language=en-US`)
// .then(response => (
// this.film_key=response.data.results[0].key
// ))
axios
.get(`https://api.themoviedb.org/3/movie/${this.m_id}?api_key=&language=en-US`)
.then(response => (
this.loading = false,
this.film_title=response.data.original_title,
this.film_tagline=response.data.tagline,
this.film_overview=response.data.overview,
this.film_poster_path=response.data.poster_path,
this.film_genres=response.data.genres,
this.film_genres_1=response.data.genres[0].name,
this.film_genres_2=response.data.genres[1].name,
this.film_genres_3=response.data.genres[2].name,
this.film_genres_4=response.data.genres[3].name,
this.film_production=response.data.production_companies[0].name,
this.film_release_date=response.data.release_date,
this.film_runtime=response.data.runtime
// this.test=response.data.results[0].key
))
}
}
</script>
enter code here
this is from store.js
import Vue from 'vue'
import Vuex from 'vuex'
import Axios from 'axios';
import router from './router'
import createPersistedState from 'vuex-persistedstate'
Vue.use(Vuex)
Vue.use(Axios)
Vue.use(router)
Vue.use(createPersistedState)
export default new Vuex.Store({
state: {
video_key: [],
},
mutations: {
updateInfo (state , video_key){
state.video_key = video_key
}
},
// getters:{
// m_id : router.currentRoute.params.m_id
// },
actions: {
async fetchData({commit}){
axios.get("https://api.themoviedb.org/3/movie/" + router.currentRoute.params.m_id + "/videos?api_key=7bc75e1ed95b84e912176b719cdeeff9&language=en-US")
.then(response =>{
commit('updateInfo',response.data.results[0].key)
})
}
}
})

Vuetify styles tags are not appeared in my web page

I am working with Vuetify and try to make a web page but the vuetify components stylings are not appeared. Could you guide me. Thank you.
My code below.
<template>
<v-app>
<v-navigation-drawer v-model="sidebar" app>
<v-list>
<v-list-tile v-for="item in menuItems" :key="item.title" :to="item.path" #click>
<v-list-tile-action>
<v-icon>{{ item.icon }}</v-icon>
</v-list-tile-action>
<v-list-tile-content>{{ item.title }}</v-list-tile-content>
</v-list-tile>
</v-list>
</v-navigation-drawer>
<v-toolbar color="indigo" dark fixed app>
<v-toolbar-side-icon #click.stop="drawer = !drawer"></v-toolbar-side-icon>
<v-toolbar-title>
<router-link to="/" tag="span" style="cursor: pointer">{{ appTitle }}</router-link>
</v-toolbar-title>
<v-spacer></v-spacer>
<v-toolbar-items class="hidden-xs-only">
<v-btn flat v-for="item in menuItems" :key="item.title" :to="item.path">
<v-icon left dark>{{ item.icon }}</v-icon>
{{ item.title }}
</v-btn>
</v-toolbar-items>
</v-toolbar>
<v-content>
<router-view/>
</v-content>
</v-app>
</template>
<script>
import Vue from 'vue';
import Vuetify from 'vuetify';
import router from '#/router';
Vue.use(Vuetify);
export default {
data() {
return {
appTitle: 'MyEvents',
sidebar: false,
drawer: null,
menuItems: [
{ title: 'Home', path: '/home', icon: 'home' },
{ title: 'Sign Up', path: '/signup', icon: 'home' },
{ title: 'Sign In', path: '/signin', icon: 'home' }
]
};
}
};
</script>
<style>
expected page display like below.
But the as per code page display appear below.
Here my side navigation does not appear properly.
Are you using vue-cli for the project?
If that, you have to install the plugin vue-cli-plugin-vuetify via vue ui.
Here the link: https://vuetifyjs.com/en/getting-started/quick-start
Greetings!