【发布时间】:2021-08-27 04:42:08
【问题描述】:
我创建 vue 组件库。
从功能上讲,它可以工作,但 css 不起作用。
如何应用库的组件?
这是代码。
库组件:
<template>
<div>
<div class="authorsPreview" v-for="(item, index) in authors" :key="index">
<span class="createdAuthor">{{ item.name }} / {{ item.name_kana }}</span>
<div class="deleteAuthorBtn" v-on:click="deleteEvent" :index="index">
x
</div>
</div>
</div>
</template>
<script>
export default {
props: [
'authors'
],
methods: {
deleteEvent(e) {
const index = e.target.getAttribute('index');
this.$emit('deleteAuthor', index);
},
}
}
</script>
<style scoped>
.authorsPreview{
...
}
.createdAuthor {
...
}
.deleteAuthorBtn {
...
}
</style>
应用组件:
<template>
<div class="epub-container">
...codes...
<authors-preview v-bind:authors="authors" v-on:deleteAuthor="deleteAuthor"></authors-preview>
...codes...
</div>
</template>
<script>
import AuthorsPreview from 'authors_preview_lib';
export default {
components: {
AuthorsPreview
},
...codes...
}
</script>
<style scoped>
...This Component's code...
</style>
如何应用库的 CSS?我试过那个库的 CSS 转向不,但它没有帮助。
感谢您的收看:)
【问题讨论】:
标签: javascript css vue.js vue-component