Component is defined but never used no-unused-vars - vue.js

I have made a Vue CLI project and then started making my project.
I have made the following component named Navigation.vue:
<template>
<nav>
<div class="nav_container">
<ul>
<li><router-link to="/home">Home</router-link></li>
<li class="dropdown">
<a class="touch"
>Network Settings <i class="fas fa-angle-down"></i
><i class="fas fa-angle-up"></i
></a>
<div class="dropdown-content">
<router-link to="/dhcpIP">DHCP IP</router-link>
<router-link to="/staticIP">Static IP</router-link>
</div>
</li>
<!-- <li><router-link to="/files">Import/Export Files</router-link></li> -->
<li><router-link to="/update">Update</router-link></li>
</ul>
</div>
</nav>
</template>
<script>
export default {
name: 'Navigation',
}
</script>
<style scoped>
/* Some style */
</style>
I have then imported it in App.vue:
<template>
<div id="app">
<Navigation />
<router-view />
</div>
</template>
<script>
import Navigation from "./components/Navigation.vue";
</script>
<style scoped>
/* Some style */
</style>
finally I have main.js which I haven't modified:
import App from './App.vue'
import router from './router'
Vue.config.productionTip = false
new Vue({
router,
render: h => h(App)
}).$mount('#app')
and I get the following error:
ERROR Failed to compile with 1 errors 8:10:25 PM
error in ./src/App.vue
Module Error (from ./node_modules/eslint-loader/index.js):
\App.vue
9:8 error 'Navigation' is defined but never used no-unused-vars
The component is clearly used, yet I receive that error. I don't understand why.

You are importing Navigation but never use it on your script, declare it as component:
<template>
<div id="app">
<Navigation />
<router-view />
</div>
</template>
<script>
import Navigation from "./components/Navigation.vue";
export default {
components: {
Navigation
},
}
</script>
<style scoped>
/* Some style */
</style>

Related

When I used router in Vuejs 2 it showed blank page

I'm asking for help. I use vuejs to make my application.however when using the router it returned me a blank page.
main.js
import Vue from 'vue'
import App from './App.vue'
import 'bootstrap'
import 'bootstrap-vue'
import router from './router'
Vue.config.productionTip = false
new Vue({
router,
render: h => h(App),
}).$mount('#app')
router/index.js
import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home'
Vue.use(VueRouter)
const routes = [
{
path: '/',
name: 'Home',
component: Home
},
{
path: '/about',
name: 'About',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
},
]
const router = new VueRouter({
mode: 'history',
base: process.env.BASE_URL,
routes
})
export default router
views/Home/index.vue
<template>
<div>
<Partner />
</div>
</template>
<script>
import Partner from '../../components/partner.vue'
export default {
name: "Home",
components:{
Partner
}
}
</script>
<style>
</style>
And this is my app.vue file
<template>
<div id="app">
<div class="header">
<div class="container1">
<img src="./assets/logo.svg" />
<ul class="menu">
<li>Về chúng tôi</li>
<li>Sản phẩm</li>
<li>Đội ngũ</li>
<li>Giải thưởng</li>
<li>Đầu tư</li>
<li>Đối tác</li>
<li>Tin tức</li>
<li>Tuyển dụng</li>
<li>Liên hệ</li>
</ul>
<div class="nav-item dropdown" id="language">
<a class="nav-link " href="#" id="navbarDropdownMenuLink" role="button" data-toggle="dropdown"
aria-expanded="false">
<img src="./assets/flag-vietnam.svg" alt="">
<b class="ml-2">VN</b>
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<a class="language-Viet row" href="#">
<div class="language-popup">
<img src="./assets/flag-vietnam.svg" alt="">
<b class="ml-2">Tiếng Việt</b>
</div>
</a>
<a class="language-English row" href="#">
<div class="language-popup">
<img src="./assets/image 19.svg" alt="">
<b class="ml-2">English</b>
</div>
</a>
</div>
</div>
</div>
</div>
<Carousel />
<div class="clear"></div>
<router-view/>
</div>
</template>
<script>
import './assets/reset.css';
import './assets/grid.css';
import './assets/boostrap.css'
import Carousel from './components/Carousel.vue'
export default {
name: 'App',
components: { Carousel
},
}
</script>
Once I compile, I have no errors but a blank page.
Thanks for any help. I tried without the router view, I manage to launch the index.html once compiled for production and I have a rendering.

Unknown custom element: <firstcomponent> - did you register the component correctly

I am a beginner at Vue.js and i am having trouble creating my first component , I gave my component a name and i think i register it correctly but i am having the Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option. error .
What am i missing
Here is my FirstComponent.vue
<template>
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">Title</div>
<div class="card-body">
Send it from Vue Js
</div>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
name: "firstcomponent",
mounted() {
console.log("Component mounted successfully");
}
}
</script>
<style scoped>
</style>
My app.js
require('./bootstrap');
import Vue from 'vue';
import FirstComponent from "./components/FirstComponent";
// window.Vue = require('vue');
Vue.component('firstcomponent', require('./components/FirstComponent.vue'));
new Vue({
el: '#app',
components: {
'firstcomponent': FirstComponent
}
})
And my blade
#extends('layouts.app')
#section('content')
<template>
<div class="flex-center position-ref full-height">
<div class="content">
<firstcomponent></firstcomponent>
</div>
</div>
</template>
#endsection
In app.js, you should define which should be exported from the component. Use default will work fine:
Vue.component('firstcomponent', require('./components/FirstComponent.vue').default);

My VueJS app is not rendering - I have looked at other solutions on stack overflow but none of them seem to solve my problem

I have a simple Vue.Js App I need to render but the app is not being rendered at all.
I followed all the examples shown online and everything looks correct but I can't spot the problem. I am using Vue.js on an ASP.net application with webpack
My Index.cshtml:
#section scripts{
<environment names="Development,Production,Staging">
<script src="~/dist/js/home/bundle.js" asp-append-version="true"></script>
</environment>
}
<div id="app">
</div>
My main app.js:
import Vue from 'vue';
import VueRouter from 'vue-router';
Vue.config.performance = true;
Vue.use(VueRouter);
import store from './store/store';
import { router } from './router/router';
import App from './App.vue';
new Vue({
el: '#app',
store,
router,
render: h => h(App)
});
My App.vue:
<template>
<div>
<div class="container">
<div class="columns">
<div class="column is-3">
<section class="section">
<aside class="menu">
<p class="menu-label">
Examples
</p>
<ul class="menu-list">
<li>
<router-link :to="{ name: 'counter' }">Counter</router-link>
</li>
</ul>
<p class="menu-label">
About
</p>
<ul class="menu-list">
<li>
<router-link :to="{ name: 'moduleinfo' }">Module info</router-link>
</li>
</ul>
</aside>
</section>
</div>
<div class="column is-9">
<section class="section">
<transition name="component-fade"
mode="out-in">
<router-view></router-view>
</transition>
</section>
</div>
</div>
</div>
<notifications group="global" />
</div>
</template>
<script>
import Vue from 'vue'
import Notifications from 'vue-notification'
Vue.use(Notifications)
export default {
name: 'App'
}
</script>
<style scoped>
</style>
There are no errors being thrown, the app simply doesnt render and the only html on the page when i run the application is
<div id=app>
</div>

Vue is not detecting component

I have two components in my Vue, 'navbar' and 'articles'. 'articles' is working fine, 'navbar' is not. I am getting the error of "unknown custom element : did you register the component correctly?"
Here is my code.
Navbar.vue
<template>
<nav class="navbar navbar-expand-sm navbar-dark bg-info mb-2">
<div class="container">
Testing Vue
</div>
</nav>
</template>
app.js
Vue.component('navbar', require('./components/Navbar.vue'));
Vue.component('articles', require('./components/Articles.vue'));
const app = new Vue({
el: '#app'
});
blade.php
<body>
<div id="app">
<navbar></navbar>
<div class="container">
<articles></articles>
</div>
</div>
<script src="{{asset('js/app.js')}}"></script>
</body>
Your Navbar.vue has no model. You cannot only use a template. You need a default export (or, as you're using require, module.exports):
<template>
<nav class="navbar navbar-expand-sm navbar-dark bg-info mb-2">
<div class="container">
Testing Vue
</div>
</nav>
</template>
<script>
module.exports = {
name: 'navbar',
data: function() {
return {}
}
}
</script>

Vue js, footer not displaying

I have installed vue cli, when i try to show my navbar(component) it shows but when i try to show my footer(component)it shows.
When i show other cms pages the navbar and footer are together the text is not displaying between...
Find the image, Output:
This is my navbar where it is a component under component folder
<template>
<div>
<ul class="navbar-nav">
<li class="nav-item">
<router-link to="/" class="nav-link">Home</router-link>
</li>
<li class="nav-item">
<router-link to="/contacts" class="nav-link">Contacts Us</router-link>
</li>
<li class="nav-item">
<router-link to="/login" class="nav-link">Login</router-link>
</li>
</ul>
</div>
</template>
<script>
export default {
name: 'Navbar'
}
</script>
This is my HomePage where it is a component under component folder
<template>
<div>
test
</div>
</template>
<script>
export default {
name: 'HomePage'
}
</script>
This is App.vue Where it is inside the Src/ Folder
<template>
<div id="app">
<app-header></app-header>
<app-footer></app-footer>
<router-view></router-view>
</div>
</template>
<script>
import Navbar from '#/components/Navbar'
import Footer from '#/components/Footer'
export default {
name: 'App',
components: {
'app-header': Navbar,
'app-footer' : Footer
}
}
</script>
This the Footer Component
<template>
<div class="hello">
<footer class="text-muted">
<div class="container">
<p class="float-right">
Back to top
</p>
<p>Album example is © Bootstrap, but please download and customize it for yourself!</p>
<p>New to Bootstrap? Visit the homepage or read our getting started guide.</p>
</div>
</footer>
</div>
</template>
<script>
export default {
name: 'Footer',
data () {
return {
msg: 'Welcome to Your Vue.js App'
}
}
}
</script>
In your App.vue template you have the order of the elements wrong.
Move the <app-footer> below rhe <router-view>:
<template>
<div id="app">
<app-header></app-header>
<router-view></router-view>
<app-footer></app-footer>
</div>
</template