首先,在 .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>
形式多样,但根本思想都是分离独立文件,引入加载
更多web前端开发知识,请查阅 HTML中文网 !!