您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

vue中如何分离css

2025/12/19 14:22:43发布19次查看
vue中分离css的方法:首先在vue文件中设置“fd9a4135951412c39fe0fdabb7ba765b531ac245ce3e4fe3d50054a55f265927”;然后新建index.js文件;最后建立相对应的html、js和css文件即可。
本教程操作环境:windows7系统、vue2.9.6版,该方法适用于所有品牌电脑。
相关文章推荐:vue.js
在正常的创建和引用vue文件都是html、css、js三者在一起的,这样写起来虽然方便了,但是页面比较大或者代码比较多的情况下,即使使用组件有时代码也比较多,简单来说查找不变不利于编程,大的来说影像优化性能。将代码中的html、css、js分离出来是个很好的选择。
首先,在 .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的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product