vue给组件加css样式的方法:首先在【.vue】文件中设置相关代码;然后新建【index.js】文件,并建立对应的【record.scss】文件即可。

本教程操作环境:windows7系统、Vue2.9.6版,Dell G3电脑。
【相关文章推荐:vue.js】
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>
形式多样,但根本思想都是分离独立文件,引入加载
相关免费学习推荐:javascript(视频)
以上就是vue如何给组件加css样式的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号