小编给大家分享一下vue给组件加css样式的方法,希望大家阅读完这篇文章后大所收获,下面让我们一起去探讨吧!
vue给组件加css样式的方法:首先在【.vue】文件中设置相关代码;然后新建【index.js】文件,并建立对应的【record.scss】文件即可。
vue给组件加css样式的方法:
首先,在.vue
文件中设置如下:
<template src="./record.html"></template>
<script src="./record.js"></script>
<style src="./record.scss"></style>
新建index.js文件,如下:
import record from './record.vue';
export default record;
建立相对应的record.html、record.js、record.scss的文件,就可以了,拿.js来说:
// -- NAME --
const name = 'record';
// -- DATA --
const data = function () {
return {
};
};
// -- COMPUTED --
const computed = {
};
// -- COMPONENTS --
const components = {
}
// -- WATCH --
const watch = {
};
// -- METHODS --
const methods = {
};
// -- HOOKS --
function mounted() {
}
// == EXPORT ==
export default {
name: name,
data: data,
components: components,
computed: computed,
watch: watch,
methods: methods,
mounted: mounted
};
另一种方法可以直接引用:
<template>
<div>html</div>
</template>
<script src="./***.js"></script>
<style src="./***.css"></style>
形式多样,但根本思想都是分离独立文件,引入加载
看完了这篇文章,相信你对vue给组件加css样式的方法有了一定的了解,想了解更多相关知识,欢迎关注亿速云行业资讯频道,感谢各位的阅读!
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。