Answer the question
In order to leave comments, you need to log in
How to correctly include the style of the component?
I'm learning vue for the first day. I can not understand. I want to include the element-ui library.
Simple HelloWorld:
<!doctype html>
<html lang="{{ app()->getLocale() }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-token" content="{{ csrf_token() }}">
<link type="text/css" href="{{ asset('css/app.css') }}">
<title>{{ config('app.name') }}</title>
</head>
<body>
<div id="app">
<el-button @click="visible = true">Button</el-button>
<el-dialog :visible.sync="visible" title="Hello world">
<p>Try Element</p>
</el-dialog>
</div>
<script src="{{ asset('js/app.js') }}"></script>
</body>
</html>
require('./bootstrap');
import Vue from 'vue';
import 'element-ui/lib/theme-chalk/index.css';
import Element from 'element-ui';
Vue.use(Element);
const app = new Vue({
el: '#app',
data() {
return {
visible: false
}
},
mounted() {
console.log('test');
}
});
Answer the question
In order to leave comments, you need to log in
You need to import styles in the same place where you connect the library itself. There is no point in spreading this into different parts of the code. If the .css extensions in the js code of the main program bother your eyes, then you can make a separate module that will connect both the Element-ui library itself and styles, and connect this module to your application. In general, the documentation describes in some detail how to connect styles, and why it was done that way.
By the way, what is app.scss, and how do you connect it?
These are different module systems - more about this (and not only) here . I advise you to study all the materials from this textbook - you will have much fewer questions :)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question