在vuejs 2组件中导入css / js文件

时间:2017-01-24 14:51:35

标签: node.js webpack vuejs2 vue-component vue-loader

我有以下.vue组件文件:

<template>
....

</template>
<script>
export default { /* stuff here*/}
</script>
<style>

</style>

现在我想在此组件中包含一些css / js(由themeforest上的模板提供)文件。在标签内包含它们似乎不起作用。知道什么是错的吗?

1 个答案:

答案 0 :(得分:1)

关于如何执行此操作的文档:https://vue-loader.vuejs.org/en/start/spec.html#src-imports

<template src="./template.html"></template>
<style src="./style.css" scoped></style>
<script src="./script.js"></script>

请注意使用scoped属性。也可以使用module属性代替scopedMore details