Reputation: 1257
I'm very new to Vue and i created a navbar component that i want to load.
Here is my code:
component.vue
<template>
<html>
<head>
...
<link href="https://fonts.googleapis.com/css?family=Gudea:400,700" rel="stylesheet">
<link href="assets/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="assets/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet">
<!-- Theme Styles -->
<link href="assets/css/flatifytheme.min.css" rel="stylesheet">
<link href="assets/css/custom.css" rel="stylesheet">
...
</head>
<body>
...
<script src="assets/plugins/jquery/jquery-3.1.0.min.js"></script>
<script src="assets/plugins/bootstrap/js/bootstrap.min.js"></script>
<script src="assets/plugins/jquery-slimscroll/jquery.slimscroll.min.js"></script>
<script src="assets/plugins/waves/waves.min.js"></script>
<script src="assets/plugins/uniform/js/jquery.uniform.standalone.js"></script>
<script src="assets/plugins/switchery/switchery.min.js"></script>
<script src="assets/plugins/pace/pace.min.js"></script>
<script src="assets/js/flatifytheme.min.js"></script>
</body>
</html>
</template>
The assets
directory is in the same folder as the component.
Now the problem is that i have a lot of <link href=''>
and <scripts>
tags that load js and css files of the theme i'm using for the navbar and i don't know where to put them in the component, so i keep getting the following error:
This relative module was not found:
* ./components/testComponent in ./src/main.js, ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/App.vue?vue&type=script&lang=js&
What does this error mean? How can i fix it?
Upvotes: 1
Views: 3401
Reputation: 2071
There are two ways of doing this:
main.js
or App.vue
import '@/assets/plugins/bootstrap/css/bootstrap.min.css'
and so on...import '@/path/to/js/file'
for JS files or for CSS:<style>
@import '@/path/to/js/file';
</style>
Upvotes: 2
Reputation: 1247
Use @import in the style tag to import CSS-files.
@import './assets/plugins/font-awesome/css/font-awesome.min.css'
Also the paths to the files are incorrect, use ./
.
./assets/plugins/jquery/jquery-3.1.0.min.js
Upvotes: 1